我目前有一个 UINavigationController 的子类,它具有以下 viewDidLoad 函数。
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"HI"
style:UIBarButtonItemStylePlain
target:self
action:@selector(manage)];
[self.navigationItem setLeftBarButtonItem:leftButton];
[self.navigationBar setBackgroundImage:[[UIImage imageNamed:@"top_nav_bg.png"] stretchableImageWithLeftCapWidth:3.0 topCapHeight:0.0] forBarMetrics:UIBarMetricsDefault];
}
该 UINavigationController 子类是具有以下 viewDidLoad 的 UITabBarBarController 子类中的选项卡之一。
- (void)viewDidLoad
{
[super viewDidLoad];
// Change some of the look of the main tab bar
[self.tabBar setBackgroundImage:[[UIImage imageNamed:@"tab_nav_bg.png"] stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0]];
[self.tabBar setSelectionIndicatorImage:[[UIImage imageNamed:@"tab_nav_bg_active.png"] stretchableImageWithLeftCapWidth:2.0 topCapHeight:0.0]];
// Load the various view controllers for this view
SBHomeViewController *homeViewController = [[SBHomeViewController alloc] init];
[homeViewController.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tab_home_active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_home.png"]];
[homeViewController.tabBarItem setImageInsets:UIEdgeInsetsMake(5.0, 0.0, -5.0, 0.0)];
// The navigation controller that will hold the home view
SBMainNavigationViewController *homeNavController = [[SBMainNavigationViewController alloc] initWithRootViewController:homeViewController];
self.viewControllers = @[homeNavController];
}
一切似乎都运行良好。正在加载来自 UINavigationController viewDidLoad 的正确导航栏背景图像。但是,leftBarButtontem 根本没有设置。对于它的价值,我尝试将其设为 rightBarButtonItem,但这也不起作用。
想法?