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. Qt-状态机

    //以下示例是QT示例中的appchooser例子,使用状态机来进行图标的交互. #include <QtCore> #include <QtWidgets> class Pi ...

  2. Haskell语言学习笔记(31)ListT

    Control.Monad.Trans.List 标准库中的 ListT 的实现由于有 bug,已经被废弃. list-t 模块 这里使用 list-t 模块中的 ListT. list-t 模块需要 ...

  3. neo4j 学习-2

    Neo4j 查询例句 MATCH (john {name: 'John'})-[:friend]->()-[:friend]->(fof) RETURN john.name, fof.na ...

  4. go递归函数如何传递数组切片slice

    数组切片slice这个东西看起来很美好,真正用起来会发现有诸多的不爽. 第一,数组.数组切片混淆不清,使用方式完全一样,有时候一些特性又完全不一样,搞不清原理很容易误使用. 第二,数组切片的appen ...

  5. 奶牛易物小组 Alpha冲刺

    项目地址:https://gitee.com/rrycbar/NenuChange 1 第一天 日期:2018/6/14 1.1 今日完成任务情况以及遇到的问题. 吴建瑜: 完成任务: 1.继续完善购 ...

  6. XtraBackup 备份原理

    来着淘宝技术: http://mysql.taobao.org/monthly/2016/03/07/ https://github.com/alibaba/AliSQL 前言 Percona Xtr ...

  7. sqldatareader无法得到output参数的解决

    只需要在所有的sqldatareader结束后,加上一句就可以得到输出参数了. sdr.Close(); Object ObjCount = cmd.Parameters["@Count_P ...

  8. unity profiler - Loading.ReadObject

    关于Loading.ReadObject耗费比较高,有什么推荐的方法吗? Loading.ReadObject是Unity引擎的资源加载函数,一般出现在切换场景和加载API调用时,这其中包括纹理.网格 ...

  9. Mask_RCNN Test

  10. Mininet

    在Coursera SDN开放课程中,编程作业要用Mininet来完成.这里对Mininet做一个简单的介绍. 什么是Mininet Mininet是由一些虚拟的终端节点(end-hosts).交换机 ...