Customize displayModeButtonItem Appearance

669 views Asked by At

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");
}
1

There are 1 answers

3
user1079052 On

Try following:

UIBarButtonItem *addButton = [[UIBarButtonItem alloc]initWithImage:faceImage style:UIBarStyleDefault target:self action:@selector(addProduct:)];