Sunday, June 9, 2013

UINavigationItem setLeftBarButtonItems example in Objective C (iOS).

UINavigationItem setLeftBarButtonItems

Sets the left bar button items, optionally animating the transition to the new items.

- (void)setLeftBarButtonItems:(NSArray *)items animated:(BOOL)animated

Parameters of [UINavigationItem setLeftBarButtonItems]
An array of custom bar button items to display on the left side of the navigation bar.
Specify YES to animate the transition to the custom bar items when this item is the top item. Specify NO to set the items immediately without animating the change.

Discussion of [UINavigationItem setLeftBarButtonItems]
If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

UINavigationItem setLeftBarButtonItems example.
Assuming iOS 5 onwards add your custom buttons:

[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects: customBarItem, customBarItemSetting, nil] animated:NO];

End of UINavigationItem setLeftBarButtonItems example article.