开发者

UINavigationBar Backbutton quits app

I have a Navigation Controller in my app delegate that i am using to switch between views and that seems to work fine clicking the back button in the NavigationBar, but only when i have a UITable in the mix. But when i pushRootviewController to a standard root view controller i still see the back button in the UINavigationBar but when i click it the program quits and logs no errors.

I thought maybe something like this would work, but no luck.

开发者_C百科
CoCoachAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UIBarButtonItem *iButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStyleBordered target:self action:@selector(playThis:)];
appDelegate.navigationController.navigationItem.backBarButtonItem = iButton;
[iButton release];

Anyone have something similar happen? Any ideas?

Thanks!


Your problem is that you set the button to the navigation controller itself. you should be setting the button to the navigationItems of your Controllers inside your Navigation Controller (and remember that the backBarButtonItem is displayed on the navigation bar when the next (follow-up) view controller is visible. if that is not the behaviour you want, you should use leftBarButtonItem.) also remember that "back buttons" should have target/action set to nil as the navigation controller adds itself als target when you use it as backBarButtonItem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜