这是我的代码。我想在打开的 rootviewController 上放一个后退按钮。
- (void)selectSurah:(id)sender {
SurahTableViewController * surahTableViewController = [[SurahTableViewController alloc] initWithNibName:@"SurahTableViewController" bundle:nil];
surahTableViewController.navigationItem.title=@"Surah";
surahTableViewController.navigationItem.backBarButtonItem.title=@"Back";
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:surahTableViewController];
[self presentModalViewController:aNavigationController animated:YES];
}
最佳答案
我不相信将 Root View Controller 从导航堆栈中弹出是不可能的,但您可以通过添加一个 UIButton
作为 UIBarButtonItem
的自定义 View 来伪造它>:
UIButton *b = [[UIButton alloc]initWithButtonType:UIButtonTypeCustom];
[b setImage:[UIImage imageNamed:@"BackImage.png"] forState:UIControlStateNormal];
[b addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
self.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:b];
可以找到合适的 iOS UI 元素的 PSD here .
关于iphone - 如何在 UINavigationController 的 RootViewController 上显示后退按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11283218/