我有一个 UIViewController,它是我的静态库的一部分。这个 UIViewController 可能会在不同的应用程序中使用。某些应用程序应该能够使用当前模式以另一种导航方式呈现此 View 。
问题是:关于导航栏设计这个 UIViewController 的优雅方式是什么?目前我有以下解决方案:
- (void)viewDidLoad
{
[super viewDidLoad];
if (self.navigationController != nil) {
self.navigationItem.title = @Test;
//... set nav bar buttons
} else {
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
navBar.topItem.title = @Test;
//... set nav bar buttons and add UINavigationBar to view
}
}
最佳答案
那么优雅的方法是将通用 UIViewController 添加到 UINavigationController
这非常有用。
关于iphone - 可重用 UIViewController 中的通用导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11907329/