Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 我在名为iAction的视图中没有导航栏?_Objective C_Ios_Uinavigationcontroller_Ibaction - Fatal编程技术网

Objective c 我在名为iAction的视图中没有导航栏?

Objective c 我在名为iAction的视图中没有导航栏?,objective-c,ios,uinavigationcontroller,ibaction,Objective C,Ios,Uinavigationcontroller,Ibaction,我的主菜单(ViewController)嵌入在我在Xcode4中的故事板中添加的NavigationController中。 我的菜单中有一个按钮,显示一个新视图。要显示它,我使用: - (IBAction) display : (id) sender { if(!anotherView) anotherView = [[AnotherView alloc] initWithNibName:@"AnotherView" bundle:nil]; [self presentMod

我的主菜单(ViewController)嵌入在我在Xcode4中的故事板中添加的NavigationController中。 我的菜单中有一个按钮,显示一个新视图。要显示它,我使用:

- (IBAction) display : (id) sender
{
    if(!anotherView) anotherView = [[AnotherView alloc] initWithNibName:@"AnotherView" bundle:nil];
    [self presentModalViewController:anotherView animated:NO];
}
“我的另一个视图”及其所有对象和元素都正确显示。不包括我的NavigationController栏,它不会出现。为什么?


感谢您的建议

您正在以模式演示viewController。如果要使用导航控制器,必须将视图推送到导航堆栈上

替换

[self presentModalViewController:anotherView animated:NO];


您正在以模式呈现视图

[self.navigationController pushViewController:anotherView animated:YES]

当然,您真正想要做的不是像这样不必要地混合和匹配故事板和非故事板流,而是让故事板为您这样做

您仍然可以在不丢失导航栏的情况下以模式显示视图。请尝试以下代码:

AnotherView *tempAnotherView = [[AnotherView alloc] initWithNibName:@"AnotherView" bundle:nil];
[self setAnotherView:tempAnotherView];
[tempAnotherView release];

UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.anotherView] autorelease];
[self.navigationController presentModalViewController:navController animated:YES];
希望有帮助!:)

AnotherView *tempAnotherView = [[AnotherView alloc] initWithNibName:@"AnotherView" bundle:nil];
[self setAnotherView:tempAnotherView];
[tempAnotherView release];

UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.anotherView] autorelease];
[self.navigationController presentModalViewController:navController animated:YES];