请帮我解决这个问题,我无法添加一个按钮到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;请帮我解决这个问题,我几乎尝试过每种排列组合。
提前Thnx
发布于 2011-06-04 01:06:50
看起来您想要在模式视图中显示一个mapView。
在iPhone上,模式视图占据了整个屏幕,因此没有空间放置导航栏。因此,您不需要导航控制器。
我假设上面的代码在一个UIViewController实例中。如果是这样,只需执行以下操作:
[self presentModalViewController:mapView animated:YES/NO];在这种情况下,您应该在mapView控制器中添加一个按钮,当按下该按钮时,将执行以下操作:
[self dismissModalViewControllerAnimated:YES/NO];https://stackoverflow.com/questions/6228941
复制相似问题