Iphone 导航控制器完成按钮未显示
当我按下mainviewcontroller上的“信息”按钮时,它会以模式显示导航栏和uitextview,但不会显示“完成”按钮Iphone 导航控制器完成按钮未显示,iphone,Iphone,当我按下mainviewcontroller上的“信息”按钮时,它会以模式显示导航栏和uitextview,但不会显示“完成”按钮 - (void) modalViewAction:(id)sender self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease]; [self.view setFrame:CGRectMake(0, 0, self.view.f
- (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];
任何人都知道为什么navigationcontroller中缺少“完成”按钮
感谢您的帮助。您可以通过以下方式进行演示:
[self.navigationController presentModalViewController:self.viewController animated:YES];
您需要将其推送到导航堆栈上:
[self.navigationController pushViewControler:self.viewController animated:YES];
现在导航控制器将为您处理“后退”按钮。您必须:
我补充说:
[_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];
}
所以我的问题解决了
谢谢你的帮助如果我是以模态的方式演示的话。没有其他方法显示“完成”按钮。原因是我想在看到“完成”按钮后使用dismissmodalview。这就是为什么我不能使用PushView控制器的原因。我之前尝试使用PushView控制器,但无法使用PoptorootViewController来解除视图。我不确定您想要什么。如果你有一个后退按钮,你还需要手动弹出它吗?如果是,只需使用:[self.navigationController popViewControllerAnimated:YES];就像用户按下后退按钮一样。