У меня была идея создать подкласс UIViewController как базовый класс для моих последующих контроллеров с целью добавления кнопки «выход» к UINavigationController в моем делегате приложения.
//MyAppDelegate.m
@synthesize navigationController; //UINavigationController
//-didFinishLaunchingWithOptions...
[self.window addSubview:navigationController.view];
...
В моем MainWindow.xib у меня есть NavigationController, подключенный к .. navigationController с DashboardViewController в качестве корневого контроллера представления.
//BaseLogoutViewController.m
- (void)loadView {
UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithTitle:NSLocalizedString(@"Logout", @"")
style:UIBarButtonItemStyleBordered
target:self
action:@selector(logoutPressed)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
[super loadView];
}
// -(void)logoutPressed callback implemented
// viewDidLoad, didRecieveMemoryWarning, dealloc implemented
//DashboardViewController.h
@interface DashboardViewController : BaseLogoutViewController { }
![DashboardViewController : UIViewController](https://i.stack.imgur.com/f7IkS.png)
DashboardViewController: UIViewController
![DashboardViewController : BaseLogoutViewController](https://i.stack.imgur.com/M8JQb.png)
DashboardViewController: BaseLogoutViewController
Хорошей новостью является то, что она показывает кнопку выхода из системы, но на панели управления не отображается ее собственное представление.
BaseLogoutViewController не имеет собственного пера.
Мой вопрос: почему, когда я создаю подкласс BaseLogoutViewController, он больше не показывает мой DashboardViewController вид?