Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
189 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...