我一直在尝试创建一个导航栏后退按钮。
这是我的代码:-
UIBarButtonItem *barButton = [[[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:nil]autorelease];
self.navigationItem.rightBarButtonItem = barButton;
但它没有在导航栏上显示任何内容。
我使用的是 UIViewController,而不是 UINavigationController。
UINavigationController 是实现此目的的唯一方法吗?
非常感谢任何帮助。
任何指向好的教程的链接都会很棒。
谢谢。
最佳答案
如果 View Controller 没有导航 Controller (即 viewController.navigationController != nil),您不能以这种方式添加它。
您可以做的一件事是,如果它是由 nib 创建的,则只需将一个栏按钮项目拖到导航栏中并通过 IBAction 链接它。
关于iphone - iOS - 如何在 View Controller 中创建导航栏项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7261766/