IOS TableViewCell exc_bad_access 自动释放错误

标签 ios memory-management uitableview exc-bad-access

我在 tableviewcell 的内存管理方面遇到问题 (exc_bad_access)。
我的一个 tableviewcell 包含一个加载异步 html 数据的 uiwebview(loadHTMLString 方法),当前 Controller 设置为其委托(delegate)。
当我从我的导航 Controller 中弹出 tableviewcontroller 的速度太快时,应用程序崩溃了。

在我看来,这就是它失败的原因:
- 如果 Controller 之前的单元 deallocs => 一切正常,委托(delegate)仍然存在,我什至可以在它自己的 dealloc 方法中将其委托(delegate)设置为 nil
- 如果单元格在 Controller 之后解除分配(我猜是因为表格 View 单元格是自动释放的)=> 应用程序崩溃,因为它的委托(delegate)仍然设置为解除分配的 Controller

知道如何正确解决这个问题吗? 谢谢..

cellForRowAtIndexPath 中的代码:

...
CustomTableViewCell * cCell = (CustomTableViewCell*)cell; 
cCell.myWebView.delegate = self; 
[[cCell myWebView] loadHTMLString:html baseURL:baseURL];
....

最佳答案

尝试添加stopLoading在释放 WebView 之前释放单元格。

关于IOS TableViewCell exc_bad_access 自动释放错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11449906/

相关文章:

ios - 更新供应配置文件(分发)并保持当前 Appstore 应用程序正常运行

ios - UISearchBar 向下移动 20 像素

ios - 语音识别器后视频无法播放

iphone - 从登录服务器验证后切换到新的 View Controller

python - Numpy - 创建重叠的 3D 子数组作为内存效率高的向量

c - 强制 free() 将 malloc 内存返回给操作系统

ios - 在 tableView Cell 问题中搜索

iphone - Objective C,内存管理

ios - UIImageView 拉伸(stretch)整个 UITableViewCell 的行高

cocoa-touch - 初始化自定义 UITableViewCell