当我按下主视图控制器上的信息按钮时,它会以模态方式显示navbar和uitextview,但不会显示完成按钮。
- (void) modalViewAction:(id)sender
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];
[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
_viewController = [[ModalViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController];
navigationController.navigationBar.tintColor = [UIColor brownColor];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Done:)] autorelease];
[self.navigationController presentModalViewController:self.viewController animated:YES];
[navigationController release];
任何人都知道为什么导航控制器中缺少Done Button。
感谢您的帮助。
答案 0 :(得分:1)
你的模仿:
[self.navigationController presentModalViewController:self.viewController animated:YES];
您需要将其推入导航堆栈:
[self.navigationController pushViewControler:self.viewController animated:YES];
现在,NavigationController将为您处理后退按钮。
答案 1 :(得分:1)
您必须:
[self.navigationController presentModalViewController:newNavigationController animated:YES];
答案 2 :(得分:0)
我添加了以下声明
[_viewController.navigationItem setLeftBarButtonItem:button animated:YES];
到下面的代码,现在导航控制器上显示完成按钮
- (void) modalViewAction:(id)sender
{
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];
[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
_viewController = [[ModalViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController];
UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease];
[_viewController.navigationItem setLeftBarButtonItem:button animated:YES];
navigationController.navigationBar.tintColor = [UIColor brownColor];
[self.navigationController presentModalViewController:self.viewController animated:YES];
[self.view addSubview:navigationController.view];
[navigationController release];
}
所以我的问题已经解决了。
感谢您的帮助