Add a UINavigationBar to a UITableViewController without a UINavigationController

前端 未结 1 1001
孤城傲影
孤城傲影 2021-01-12 06:46

I have an existing UITableViewController that was previously being used in a UINavigationController.

I need to convert it to be presented as a modal view. However, I

1条回答
  •  有刺的猬
    2021-01-12 07:37

    Did you change the connection in the XIB for the File's Owner view? It should point to your outer view which contains both the navbar and tableview.

    But I'm not sure I understand why you don't want to use a navigation controller. Just do this:

    MyViewController *viewController = [[[MyViewController alloc] init] autorelease];
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:viewController] autorelease];
    [self presentModalViewController:navController animated:YES];
    

    I do this all the time when presenting a modal view - it seems cleaner than including a navbar directly in the view.

    0 讨论(0)
提交回复
热议问题