1

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");
}
Lukas Würzburger
  • 6,543
  • 7
  • 41
  • 75
raginggoat
  • 3,570
  • 10
  • 48
  • 108

1 Answers1

-1

Try following:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithImage:faceImage style:UIBarStyleDefault target:self action:@selector(addProduct:)];
Hima
  • 1,249
  • 1
  • 14
  • 18
user1079052
  • 3,803
  • 4
  • 30
  • 55
  • This works, but why would my code work on the iPad but not the iPhone? – raginggoat Feb 03 '16 at 16:18
  • Are you using one storyboard for both devices? Have you cleaned the project and deleted the derived data in a while? What do you mean by not working? Is it not going to the method on the iPhone? – user1079052 Feb 03 '16 at 17:09
  • I'm actually not using a storyboard. By not working, I mean the bar button item to show the master view controller works on the iPad but not on the iPhone after I've implemented the code from my post. – raginggoat Feb 03 '16 at 17:11