IOS Add right button to navigation bar not working
===

It works with ViewController that does not have tab bar but not with tab bar.
Also, this is the first view controller in the story board.

<i>    UIImage *bookmarkImage = [UIImage imageNamed:@"bookmark"];
    
    //create the button and assign the image
    UIButton *bookmarkButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    //set the frame of the button to the size of the image (see note below)
    bookmarkButton.frame = CGRectMake(100, 0, bookmarkImage.size.width,      bookmarkImage.size.height);
    [bookmarkButton setImage:bookmarkImage forState:UIControlStateNormal];
    
    [bookmarkButton addTarget:self action:@selector(addFavorite:) forControlEvents:UIControlEventTouchUpInside];
    bookmarkButton.imageView.contentMode=UIViewContentModeScaleAspectFit;
    
    //create a UIBarButtonItem with the button as a custom view
    UIBarButtonItem *customBarItem2 = [[UIBarButtonItem alloc] initWithCustomView:bookmarkButton];
    self.navigationItem.rightBarButtonItem = customBarItem2;
</i>