开发者

iPhone - unrecognized selector sent to instance - Trying to open the starting view after viewing several other views

I am just starting with iPhone programming. I used the utility application project template. A button on the main view of the utility application calls another view which shows some data. At the end of the presentation of the data a "end" view is shown. The "end" view contains a button to return to the main view. This all works great, however once you return to the mainview and try either to click the info button or click the button to call the data view the application terminates with the following error:

-[TheEVController startS]: unrecognized selector sent to instance 0x3933d90

EVController.m 
- (IBAction)done { 
EVController *controller = [[EV alloc] initWithNibName:@"MainView" bundle:nil]; //controller.delegate = self; 
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:controller animated:YES]; 
[controller release];
}

MainViewController.m 
- (IBAction)startS { 
SVControl开发者_StackOverflow中文版ler *controller = [[SVController alloc] initWithNibName:@"SView" bundle:nil]; controller.delegate = self; 
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:controller animated:YES]; 
[controller release]; 
}

Any suggestions?


If you want to call startS, which is a method on a MainViewController object, you can't call it on an EVController object.

[TheEVController startS];

tells the Objective-C runtime that you want to invoke the startS method in the TheEVController's class (or one of its parent classes).

It's not entirely clear from the code you posted (you didn't actually show us the section of code that is causing the exception) but from your description it sounds like you're overwriting a UIView variable that initially points to your MainViewController with a pointer to an EVController, and not resetting that variable when you show your MainViewController again.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜