【问题标题】:UINavigationController and UITableView issues in modalViewmodalView 中的 UINavigationController 和 UITableView 问题
【发布时间】:2011-05-09 00:43:33
【问题描述】:

我有以下代码:

- (IBAction)showDirectMessage:(id)sender
{
    DetailMessageViewController * dmvc = [[DetailMessageViewController alloc] init];
    dmvc.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:dmvc animated:YES];
}

我在这里要做的是呈现一个顶部有一个 NavigationBar 和一个 UITableView 作为内部视图的视图。但是到目前为止,它只显示 UITableView。我对我需要改变什么感到困惑。在我的 DetailMessageViewController IB 中,我拖入 UINavigationController 并将 UITableView 作为视图放入内部。但是,我将 UINavigationController 连接到 UITableView 视图的.. 我认为这是错误的。我不知道我该怎么做。有人可以指导我吗?

【问题讨论】:

    标签: iphone objective-c ipad


    【解决方案1】:

    您应该使用 ViewController 呈现新的 NavigationController。

    - (IBAction)showDirectMessage:(id)sender
    {
        DetailMessageViewController * dmvc = [[DetailMessageViewController alloc] init];
        UINavigationController *naviContoroller = [[UINavigationController alloc] initWithRootViewController:dmvc];
        naviContoroller.modalPresentationStyle = UIModalPresentationFormSheet;
    
        [self presentModalViewController:naviContoroller animated:YES];
    
        [naviContoroller release];
        [dmvc release];
    }
    

    【讨论】:

    • 并且U可以使用“dmvc.navicationItem”来设置navigationBar属性,如标题、左右栏按钮项等。
    • 好吧...那么 IB 中 UINavigationController 的用途是什么?
    • 我想你想将 UINavigationBar 与你的 ViewController 一起使用。它将帮助您了解“iOS 视图控制器编程指南”,您应该阅读“iOS 视图控制器编程指南”bit.ly/lNvE1y 上的自定义视图控制器剖析(以下链接) - 需要苹果开发人员登录。
    【解决方案2】:
    DetailMessageViewController *dmvc=[[[DetailMessageViewController alloc]initWithNibName:@"DetailMessageViewController" bundle:nil]autorelease];    
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:dmvc]autorelease];
    [navController setModalTransitionStyle:UIModalPresentationFormSheet];
    [[self navigationController] presentModalViewController:navController animated:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      相关资源
      最近更新 更多