How to call IBAction in subview?

旧城冷巷雨未停 提交于 2019-12-13 08:52:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!