MacDev 板


LINE

第一次发文如有不妥麻烦告知感恩 目前正在做关於录影存档的程式 碰上於删除表格後所发生crash的问题 - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *path = [dirs objectAtIndex:0]; NSString *FileName =[[[NSString alloc]initWithString:path] stringByAppendingPathComponent:@"/"]; NSInteger sumnumber=0,partnumber=0; //底下的video是一维阵列存放影片 我在读video内容时将section内的row数加总 for (int j=0; j<indexPath.section; j++) { //recordrownumber记录各section的row数 partnumber=[[recordrownumber objectAtIndex:j] integerValue]; sumnumber=sumnumber+partnumber; } partnumber=[indexPath row]; sumnumber+=partnumber; //移除video内存放影片的路径 NSString *firstFileName = [video objectAtIndex:sumnumber]; FileName=[FileName stringByAppendingPathComponent:firstFileName]; [[NSFileManager defaultManager]removeItemAtPath:FileName error:nil]; [video removeObjectAtIndex:sumnumber]; [self.tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft]; } 错误的是这一行(当我把这行注解掉就不会crash) [self.tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft]; 其错误原因 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 3. The number of rows contained in an existing section after the update (6) must be equal to the number of rows contained in that section before the update (6), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).' *** First throw call stack: (0x326bf88f 0x34715259 0x326bf789 0x37fe43a3 0x3219dd1d 0x3219b8f3 0x3221426b 0x405e7 0x3222e08d 0x326193fd 0x32101e07 0x32101dc3 0x32101da1 0x32101b11 0x32102449 0x3210092b 0x32100319 0x320e6695 0x320e5f3b 0x3176d22b 0x32693523 0x326934c5 0x32692313 0x326154a5 0x3261536d 0x3176c439 0x32114cd5 0x3e10d 0x3e0a8)terminate called throwing an exception(lldb) 网路上找了很多资料 现在一个头两个大完全不知道该怎麽修改才是 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 1.174.90.198
1F:→ j5307:另外我的section数 大於1 09/21 17:25
2F:→ chd75131:因为你只是把tableview上的cell删除 你使用的datasource 09/22 01:35
3F:→ chd75131:并没有跟着更新 所以会造成你datasource的数目会大於实际 09/22 01:36
4F:→ chd75131:tableview上所显示的资料 所以当你delete row时记得 09/22 01:37
5F:→ chd75131:module也要更新 然後最好用[tableview beginupdate] 09/22 01:38
6F:→ chd75131:跟[tableview endupdate]包起来 09/22 01:38
7F:→ j5307:我已经解决这问题了 谢谢 09/22 10:21







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP