Pressinsg the right bar button, Showed NCFSString unrecognized selector.. on restarting, I get n开发者_如何学运维o helpful stack trace.
-(void)nextIntroStage{
_introStage++;
if (_introStage < _maxIntro) {
[self showIntroPicture];
} else {
[self finishedIntro];
}
}
-(void)viewDidLoad {
[super viewDidLoad];
_introStage = 0;
_maxIntro = 3;
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(nextIntroStage)];
self.navigationItem.rightBarButtonItem = nextButton;
Strange, switched it to leftBarButtonitem and am getting "NSURL nextIntroStage".. but I'm not using an NSURL anywhere in my app. Some kind of memory issue, sure, but what?
Only relevant thing I can think of is in my app delegate I'm doing
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:nc.view];
[window makeKeyAndVisible];
[nc release];
The addSubview:
method only retains the view you have added, not the navigation controller. By releasing that navigation controller with [nc release]
, you are essentially destroying that view's navigationController.
Move the declaration for nc
to your .h, initialise it as usual in your didFinishLaunchingWithOptions
and release it in your dealloc
.
精彩评论