“Normal” UIButton causing obj_stack_overflow or EXC_BAD_ACCESS exception

孤街浪徒 提交于 2019-12-04 10:16:11

The problem is right there in your first code snippet: you’re creating an instance of TipsViewController, retaining its view, then releasing the view controller--which will cause it to be deallocated. So now the target of the buttons is a pointer to the deallocated view controller.

A view does not retain its view controller, nor do they retain their delegates or targets.

You'll have to keep the view controller instance retained—perhaps in a retain property—for as long as you want the view to be displayed. When you're done with the view, you can remove it from its parent view, and release the view controller.

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