Reputation: 10245
I am animating to a view with it sliding from right to left. The left bar button looks like it is in the navigation but the rightbarbutton seems to animated weirdly, almost like at first its not part of the navigation bar.
I am wanting to know if there is something wrong in my code... or if there is another way of doing this?
- (void)viewWillAppear:(BOOL)animated
{
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Skip" style:UIBarButtonItemStyleBordered target:nil action:nil];
[super viewWillAppear:animated];
}
Any help would be greatly appreciated.
Upvotes: 2
Views: 63
Reputation: 23722
Set rightBarButtonItem
in the view controller's init...
method. It only has to be done once in the view controller's lifetime.
Upvotes: 3
Reputation: 8845
This is just a shot in the dark, but the convention is to first call [super viewWillAppear:animated], then add your own code. Do that whenever you're constructing things (objects, views, etc).
Then when tearing things down (-dealloc, -viewWillDisappear, etc.), do the opposite. Clean up your stuff, then call the super to let it do its cleanup.
That probably isn't related and won't make a difference. But it's a good habit to get in to, and you never know. It might change the behavior here. Maybe the super needs to do do some setup before you add the bar button item.
Upvotes: 1