UINavigationBar refuses to show in Modal View Controller

北慕城南 提交于 2019-12-06 04:42:54

sha's answer is correct, but I'm giving my own answer to expand on it with a code example to make it clear.

You probably want something like:

- (void)showAccountViewController
{
    AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:@"AccountView" bundle:nil];
    ...
    // Initialize properties of accountViewController
    ...
    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
    [self.navigationController presentModalViewController:navController animated:YES];
    [navController release];
    [accountViewController release];
}

You need to push not viewController but navigationController that has viewController inside.

You can also set the presentation style in the Attribute Inspector to "Current Context". Modal View will not cover the Navigational Bar.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!