首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iphone :无法在导航栏上显示后退按钮

问iphone :无法在导航栏上显示后退按钮
EN

Stack Overflow用户
提问于 2011-06-03 23:11:59
回答 1查看 468关注 0票数 1

请帮我解决这个问题,我无法添加一个按钮到modalview的导航栏

代码语言:javascript
复制
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;

请帮我解决这个问题,我几乎尝试过每种排列组合。

提前Thnx

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-04 01:06:50

看起来您想要在模式视图中显示一个mapView。

在iPhone上,模式视图占据了整个屏幕,因此没有空间放置导航栏。因此,您不需要导航控制器。

我假设上面的代码在一个UIViewController实例中。如果是这样,只需执行以下操作:

代码语言:javascript
复制
  [self presentModalViewController:mapView animated:YES/NO];

在这种情况下,您应该在mapView控制器中添加一个按钮,当按下该按钮时,将执行以下操作:

代码语言:javascript
复制
  [self dismissModalViewControllerAnimated:YES/NO];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6228941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档