【问题标题】:adding navigation bar to detailview and tableview向detailview和tableview添加导航栏
【发布时间】:2012-03-28 06:41:16
【问题描述】:

i am developing an iPhone app in which there is a uitableview and a when any of the rows in the table view is selected, a new viewcontroller will be loaded which shows details about the selected row in the tableview .我的问题是我需要表格视图和详细信息视图中的导航栏,导航栏应该有后退按钮,即详细信息视图上的导航栏应该有一个后退按钮到表格视图应该有一个后退按钮到早期视图控制器。如何我以编程方式执行此操作??

【问题讨论】:

  • 看来你对iOS开发很陌生。所以最好继续阅读本教程icodeblog.com/2008/08/08/…。 B4 你发布你的问题,请搜索它的教程。询问您在哪里遇到错误或类似的问题。
  • @hpiOSCoder 我已经尝试过可能的教程,但似乎确实有助于我为什么在这里问它。抱歉给您带来麻烦
  • 嘿伙计,无需抱歉,我们都在这里互相帮助。为什么我这么建议你,因为你的简单问题可能会得到“否决票”,这将反映你的堆栈溢出声誉。 .所以b4你问只是检查教程。顺便说一句,如果我的链接对您有所帮助,请投票给我的评论。 :)

标签: iphone objective-c ios ipad ios5


【解决方案1】:

带有 tableview 的视图控制器应该是导航控制器的根视图控制器(您可以通过编程方式创建)。然后你只需推送 (pushviewcontroller:animated:) 详细视图控制器。

【讨论】:

    【解决方案2】:
    @implementation UINavigationBar (CustomImage)
    
      - (void)drawRect:(CGRect)rect
      {
         NSLog(@"self.topItem.title = %@", self.topItem.title);
         CGRect frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
         UIImage *image = [UIImage imageNamed: @"background.png"];
         [image drawInRect:frame];
         UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
         [label setBackgroundColor:[UIColor clearColor]];
         label.font = [UIFont boldSystemFontOfSize: 20.0];
         //label.shadowColor = [UIColor colorWithWhite:1.0 alpha:1];
         label.textAlignment = UITextAlignmentCenter;
         label.textColor = RGBCOLOR(73, 81, 85);
         label.text = self.topItem.title;
         self.topItem.titleView = label;
        self.tintColor = RGBCOLOR(229, 239, 246);
      }
     @end
    

    还添加 UIButton 和它的 Action 事件以在视图控制器之间导航

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2021-04-09
      • 1970-01-01
      • 1970-01-01
      • 2019-02-20
      • 2018-10-24
      • 1970-01-01
      相关资源
      最近更新 更多