[英]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.