[英]iphone : unable to show back button on navigation bar
请帮帮我这真的很不稳定我无法在modalview的导航栏中添加按钮
UINavigationController *tempModalVC=[[UINavigationController alloc] init];
[tempModalVC.navigationBar setBarStyle:UIBarStyleBlack];
//UIBarButtonItem *tempDoneBTN=[[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStylePlain target:self action:@selector(hideModalView:)];
UIBarButtonItem *tempDoneBTN=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(hideModalView:)];
[tempModalVC.navigationItem setBackBarButtonItem:tempDoneBTN];
[tempModalVC.navigationItem setTitle:@"Title"];
tempModalVC.navigationItem.backBarButtonItem.enabled=YES ;
//[tempModalVC.navigationBar setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:@selector(hideModalView:)]];
//[tempModalVC.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:@selector(hideModalView:)]];
[tempDoneBTN release];
[tempModalVC.view addSubview:mapView];
tempModalVC.modalPresentationStyle = UIModalPresentationFormSheet;
请帮我解决这个问题,我已经尝试了几乎所有的排列组合。
提前谢谢
看起来好像您想在模态视图中显示 mapView。
在 iPhone 上,模态视图占据了整个屏幕,因此没有导航栏的空间。 因此,您不需要导航 controller。
我假设上面的代码在 UIViewController 实例中。 如果是这样,只需执行以下操作:
[self presentModalViewController:mapView animated:YES/NO];
在这种情况下,在您的 mapView controller 中,您应该添加一个按钮,当按下该按钮时:
[self dismissModalViewControllerAnimated:YES/NO];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.