UINavigationBar pushNavigationItem animated
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
Parameters
item
The navigation item to push on the stack.
animated
YES if the navigation bar should be animated; otherwise, NO.
Discussion of [UINavigationBar pushNavigationItem animated]
Pushing a navigation item displays the item’s title in the center on the navigation bar. The previous top navigation item (if it exists) is displayed as a back button on the left side of the navigation bar. If the new top item has a left custom view, it is displayed instead of the back button.
UINavigationBar pushNavigationItem animated example.
On your navigationbar reference you could invoke the two methods:
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated
In your custom view controller class write something like this:
self.navigationItem.leftBarButtonItem = yourButton;
self.navigationItem.rightBarButtonItem = yourSecondButton;
So you could write something like this:
[myNavBarReference pushNavigationItem:self.navigationItem animated:NO];
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated
- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated
In your custom view controller class write something like this:
self.navigationItem.leftBarButtonItem = yourButton;
self.navigationItem.rightBarButtonItem = yourSecondButton;
So you could write something like this:
[myNavBarReference pushNavigationItem:self.navigationItem animated:NO];
Example of [UINavigationBar pushNavigationItem animated].
Try using the navigation item's title property for this:
UINavigationItem *item = [[[UINavigationItem alloc] initWithTitle:@"Login"] autorelease];
[yourNavigationBar pushNavigationItem:item animated:NO];
UINavigationItem *item = [[[UINavigationItem alloc] initWithTitle:@"Login"] autorelease];
[yourNavigationBar pushNavigationItem:item animated:NO];
UINavigationBar pushNavigationItem animated example.
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self
action:@selector(toggleHelpGame)];
UINavigationItem *navigationItem = [[UINavigationItem alloc]
initWithTitle:@"Help"];
navigationItem.rightBarButtonItem = buttonItem;
[navigationItem setLeftBarButtonItem:nil];
[self.sideNavigationBarCtrl pushNavigationItem:navigationItem
animated:NO];
[navigationItem release];
[buttonItem release];
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self
action:@selector(toggleHelpGame)];
UINavigationItem *navigationItem = [[UINavigationItem alloc]
initWithTitle:@"Help"];
navigationItem.rightBarButtonItem = buttonItem;
[navigationItem setLeftBarButtonItem:nil];
[self.sideNavigationBarCtrl pushNavigationItem:navigationItem
animated:NO];
[navigationItem release];
[buttonItem release];