问题
When I try to call IBAction in root view it works, but when I call in subView app creashes.
Code:
- (IBAction)webButton:(id)sender {
NSLog(@"doesn't print log");
}
Here is ss off crash: http://dl.dropbox.com/u/77033905/urlInSafariCrashesUp.png
Thank's for help
UPDATE: Example code: http://dl.dropbox.com/u/77033905/IBActionSubView.zip
回答1:
When you create your SubViewController, the variable sub
that points to it is local to the addSubViewButton:
method and will be released when that method ends. You need to keep a strong reference to that controller so that it's not deallocated before you use it.
来源:https://stackoverflow.com/questions/10515259/how-to-call-ibaction-in-subview