I have a viewController with a UITableView, the rows of which I allow to edit (delete) with a swipe - much like in the Mail app. I do it with, among other, this method:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

    return YES;
}

However, if I have a delete button revealed, and at the same time I use back navigation of my UINavigationController, i.e. when I popViewControllerAnimated:, the app crashes with the following message:

[ViewController tableView:canEditRowAtIndexPath:]: message sent to deallocated instance 0xaae64d0

How can I resolve this problem?

In your view controller's dealloc method, set the table view's editing property to NO.

answered Oct 8 '13 at 8:41
Guy Kogus
3,96811023
 
6  
   
This works but it only started happening in iOS7. Any idea why? –  Imran Oct 26 '13 at 10:49
15  
   
Because Apple's written some buggy code. –  Guy Kogus Oct 27 '13 at 22:50
    
   
Hope we are all submitted Bug Reports :) –  burrows111 Jan 20 '14 at 13:54
    
   
At first, I thought this is a random crash because of system bugs because crashlytics tells me only few people(out of thousands) having this issue. Now I know why and get my app fixed! –  benck Feb 16 '14 at 9:17
1  
   
Nice find. I see Apple still hasn't fixed this. –  Tander Mar 10 at 9:32
   

I had the same problem, but I was using ARC and I didn't want to be mucking about in the dealloc method. Doing it in viewWillDisappear was sufficient to stop the crash.

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[table setEditing:NO];
}
answered Oct 8 '13 at 16:14
 

    
   
Is it wrong to have a dealloc method under ARC as long as you don't call [super dealloc]? –  artooras Oct 9 '13 at 9:27
   upvote
  flag
It's not wrong. The accepted answer won't break anything and will compile normally. You literally won't be allowed to call [super dealloc] or release as ARC is supposed to call them for you. My suggestion was mostly to reduce confusion since I didn't want an unusual dealloc method when none of my other classes have one. It also feels weird to be setting a property on an object moments before it will likely be released. –  Nathan Rabe Oct 9 '13 at 15:39
3  
   
This method will sometimes cause weird behaviour if you present other vcs etc so I would use the dealloc method. –  Imran Oct 26 '13 at 10:51
1  
   
viewDidDisappear: also works, which I prefer in this case as the user doesn't see the tableview transitioning out of the editing state. –  Defragged Mar 6 '14 at 13:20
1  
   
Thank you.... I also had this issue on iOS7 only.... –  lepert Mar 25 '14 at 4:42

TableView编辑状态下跳转页面的崩溃处理的更多相关文章

  1. iOS开发UI篇-tableView在编辑状态下的批量操作(多选)

    先看下效果图 直接上代码 #import "MyController.h" @interface MyController () { UIButton *button; } @pr ...

  2. easyui 在编辑状态下,动态修改其他列值。

    首先是自定义了一个方法uodateColumn更新列值 /** *自定义的修改列值方法 */ $.extend($.fn.datagrid.methods, { updateColumn: funct ...

  3. datagrid combobox事件更新编辑状态下的datagrid行

    请问如何从上图状态 点击下拉的combobox中值然后在不取消datagrid编辑状态下更新这一行另一列的数据,达到下图这样的效果: 非常感谢! 给你的combobox  绑定一个onSelect 事 ...

  4. ubuntu中vi在编辑状态下方向键不能用的解决

    ubuntu中vi在编辑状态下方向键不能用,还有回格键不能删除等,我们平时习惯的一些键都不能使用. 解决办法: 可以安装vim full版本,在full版本下键盘正常,安装好后同样使用vi命令. 安装 ...

  5. tableview 编辑状态设置

    #pragma mark - tableview 编辑状态设置 -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSI ...

  6. 解决:WdatePicker新增状态下只能取比当前月份大的月份,编辑状态下只能取比当前input里指定月份的月份大的值

    onclick="WdatePicker({ dateFmt: 'yyyy-MM', autoPickDate: true, minDate: this.value==''?'%y-#{%M ...

  7. ListView在编辑状态下不能获取修改后的值,无法更新数据

    ListView在编辑状态下不能获取修改后的值,获取到的总是以前的值解决方法:在page_load事件里写: if(!IsPostBack) { ListViewBind(); } 原因:这涉及到as ...

  8. odoo14 编辑状态和非编辑状态下隐藏

    1 <div class="oe_edit_only"> 2 <a name="remove_group_id" type="obj ...

  9. dateTimePicker编辑状态下,取值不正确的问题

    当对dateTimePicker进行编辑,回车,调用函数处理dateTimePicker的value值时,其取值结果是你编辑之前的值,而不是你编辑后的值,虽然dateTimePicker.text的值 ...

随机推荐

  1. TCP/IP知识总结(TCP/IP协议族读书笔记三)

    接下来,总结传输层的两大协议UDP和TCP. 一.UDP(用户数据报协议) 讲UDP之间,先了解两个概念:有连接和无连接. 有连接:通信之前,通信双方必须建立一条通道: 无连接:不需要建立通道,发送方 ...

  2. ArcGIS案例学习笔记1_1

    ArcGIS案例学习笔记1_1 联系方式:谢老师,135_4855_4328, xiexiaokui#qq.com 时间:第一天上午 准备 0.U盘复制ArcGIS培训*** 1.练习数据不要放到桌面 ...

  3. 必备 .NET - C# 脚本

    作者:Mark Michaelis | 2016 年 1 月 Link: https://msdn.microsoft.com/zh-cn/magazine/mt614271.aspx 随着 Visu ...

  4. 深入MySQL用户自定义变量

    一.到底MySQL的变量分哪几类? MySQL变量一共分为两大类:用户自定义变量和系统变量.如下: 用户自定义变量 局部变量 会话变量 系统变量 会话变量 全局变量 本文涉及的内容为用户自定义会话变量 ...

  5. springboot取得resources下的文件

    参考http://blog.csdn.net/programmeryu/article/details/58002218 ResourceUtils.getFile("classpath:p ...

  6. Hibernate中一级缓存和二级缓存

    缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据,在特定的时刻或事 ...

  7. javascript基础代码

    1.点击改变HTML内容 <html> <head> <meta charset="UTF-8"> <script> functio ...

  8. 85. Maximal Rectangle (Graph; Stack, DP)

    Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...

  9. 几种TCP连接终止

    在三次连接完成后,accept调用前,客户机发来RST. Berkeley实现将完全在内核中处理,不通知. 而SVR4实现将返回一个错误EPROTO,而POSIX指出应该是ECONNABORTED,后 ...

  10. python之字典【dict】

    #Auther Bob#--*--conding:utf-8 --*-- #创建一个字典dictdic1 = {'k1':'v1','k2':'v2'}dic2 = dict(k1='v1',k2=' ...