I’m working on an app for iPad and iPhone, I’ve added multiple bar items to the navigation bar, but I want to add different bar items…
In the navigation bar from the iPad I just want to add 2 items to the right, which is already working. But I also want to add 2 other buttons to the left side of the iPhone navigation bar. But with the way that I’m trying it I get the same navigation bars, the same items, any ideas on how to add different items to the navigation bars.
Here’s my code:
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action: @selector(IpadReload:)];
UIImage *emailIcon = [UIImage imageNamed:@"emailicon.png"];
UIBarButtonItem *emailButton = [[UIBarButtonItem alloc] initWithImage:(emailIcon) style:UIBarButtonItemStylePlain target:self action:@selector(emailButtonTapped:)];
NSArray *rightButtonsArray = [[NSArray alloc] initWithObjects:refreshButton, emailButton, nil];
self.navigationItem.rightBarButtonItems = rightButtonsArray;
UIBarButtonItem *previousButton = [[UIBarButtonItem alloc] initWithTitle:@"Previous" style:UIBarButtonItemStylePlain target: self action: @selector(PreviousClicked:)];
UIImage *phoneIcon = [UIImage imageNamed:@"phoneicon.png"];
UIBarButtonItem *phoneButton = [[UIBarButtonItem alloc] initWithImage:(phoneIcon) style:UIBarButtonItemStylePlain target:self action:@selector(callPhone:)];
NSArray *leftButtonsArray = [[NSArray alloc] initWithObjects:previousButton, phoneButton, nil];
self.navigationItem.leftBarButtonItems = leftButtonsArray;
Actually, you need to use iOS’s built in enum of the current device and not isEqualToString: