我有一个 UINavigationController,我的 AHViewController 作为根视图控制器。
然后我尝试从 AHViewController 的 viewDidLoad 中添加一个左栏按钮项:
UIButton * backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton addTarget:self action:@selector(backButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[backButton setImage:[UIImage imageNamed:@"grid.png"] forState:UIControlStateNormal];
UIBarButtonItem *backButtonBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
//[self.navigationItem setLeftBarButtonItem:backButtonBarItem];
[self.navigationController.navigationItem setLeftBarButtonItem:backButtonBarItem];
[backButtonBarItem release];
但是,我什么也没看到。为什么是这样?