我的代码是:
- (void) tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath{
if (editingStyle == UITableViewCellEditingStyleDelete){
/* First remove this object from the source */
[self.allRows removeObjectAtIndex:indexPath.row];
/* Then remove the associated cell from the Table View */
[tableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}
}
我收到如下错误
2015-02-16 11:57:32.413 SimpleTable [1590:45462]-[ViewController refreshControl]:无法识别的选择器已发送到实例0x7fa1d2d936c0 2015-02-16 11:57:32.415 SimpleTable [1590:45462] ***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[ViewController refreshControl]:无法识别的选择器已发送至实例0x7fa1d2d936c0' ***首先抛出调用堆栈: ( 0 CoreFoundation 0x000000010d738f35 __exceptionPreprocess + 165 1个libobjc.A.dylib 0x000000010d3d1bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010d74004d-[NSObject(NSObject)didNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010d69827c ___转发___ + 988 4 CoreFoundation 0x000000010d697e18 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010db268be-[UIApplication sendAction:to:from:forEvent:] + 75 6 UIKit 0x000000010db268be-[UIApplication sendAction:to:from:forEvent:] + 75 7 UIKit 0x000000010dc2d410-[UIControl _sendActionsForEvents:withEvent:] + 467 8 UIKit 0x000000010dc2c7df-[UIControl touchesEnded:withEvent:] + 522 9 UIKit 0x000000010db6c308-[UIWindow _sendTouchesForEvent:] + 735 10 UIKit 0x000000010db6cc33-[UIWindow sendEvent:] + 683 11 UIKit 0x000000010db399b1-[UIApplication sendEvent:] + 246 12 UIKit 0x000000010db46a7d _UIApplicationHandleEventFromQueueEvent + 17370 13 UIKit 0x000000010db22103 _UIApplicationHandleEventQueue + 1961 14 CoreFoundation 0x000000010d66e551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 15 CoreFoundation 0x000000010d66441d __CFRunLoopDoSources0 + 269 16 CoreFoundation 0x000000010d663a54 __CFRunLoopRun + 868 17 CoreFoundation 0x000000010d663486 CFRunLoopRunSpecific + 470 18 GraphicsServices 0x0000000110d079f0 GSEventRunModal + 161 19 UIKit 0x000000010db25420 UIApplicationMain + 1282 20个SimpleTable 0x000000010cea27d3 main + 115 21 libdyld.dylib 0x000000010fcc8145开始+ 1 ) libc ++ abi.dylib:以类型为NSException的未捕获异常终止 (lldb)
我认为您的TableView在创建后可能会被释放,并且该方法结束。您可能需要在View控制器中创建引用它的实例变量。
@property (strong, nonatomic) IBOutlet UITableView *tablview;
然后从表格视图中删除关联的单元格
[self.tablview deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
可以帮助你..
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句