I'm trying to use an image for my displayModeButtonItem
in my UISplitViewController
. I get the item looking like I want it but it doesn't do anything when tapped on an iPhone. It works fine when using an iPad.
UIBarButtonItem *menuItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"list_button"]
style:UIBarButtonItemStylePlain
target:self.splitViewController.displayModeButtonItem.target
action:self.splitViewController.displayModeButtonItem.action];
self.navigationItem.leftBarButtonItem = menuItem;
I've added a check to make sure displayModeButtonItem
is not nil
and it is indeed not nil
.
if (self.splitViewController.displayModeButtonItem == nil) {
NSLog(@"displayModeButtonItem is nil");
} else {
NSLog(@"displayModeButtonItem is NOT nil");
}
Try following: