iphone - 如何在 UINavigationController 的 RootViewController 上显示后退按钮?

标签 iphone ios xcode uinavigationcontroller uibarbuttonitem

这是我的代码。我想在打开的 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/

相关文章:

iphone - iOS : Detecting when the multitasking bar has been opened

iphone - iOS 上的软件即服务需要订阅吗?

iphone - 带有弯曲端的iOS Draw Rectangle

iphone - 如何更改启动的默认 xcode 版本...?

xcode - 使用 swift 为 Mac 应用程序获得管理权限

iphone - iOS AWS S3 实现教程

ios - UITextField 只接受一位小数点,小数点前最多 3 位,小数点后最多 2 位

ios - EXC_BAD_ACCESS KERN_INVALID_ADDRESS for WKWebView dealloc

iphone - 更改父 View Controller 容器中的标签

iphone - 在头文件中使用变量和常量定义进行本地化