运行时未捕获的异常 'NSInvalidArgumentException' 错误
uncaught exception 'NSInvalidArgumentException' error during runtime
我的代码是:
- (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 核心基础 0x000000010d738f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d3d1bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010d74004d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 核心基础 0x000000010d69827c ___forwarding___ + 988
4 核心基础 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 发送事件:] + 683
11 UIKit 0x000000010db399b1 -[UIApplication sendEvent:] + 246
12 UIKit 0x000000010db46a7d _UIApplicationHandleEventFromQueueEvent + 17370
13 UIKit 0x000000010db22103 _UIApplicationHandleEventQueue + 1961
14 核心基础 0x000000010d66e551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 核心基础 0x000000010d66441d __CFRunLoopDoSources0 + 269
16 核心基础 0x000000010d663a54 __CFRunLoopRun + 868
17 核心基础 0x000000010d663486 CFRunLoopRunSpecific + 470
18 图形服务 0x0000000110d079f0 GSEventRunModal + 161
19 UIKit 0x000000010db25420 UIApplicationMain + 1282
20 简单表 0x000000010cea27d3 主 + 115
21 libdyld.dylib 0x000000010fcc8145 开始 + 1
)
libc++abi.dylib:以 NSException 类型的未捕获异常终止
(lldb)
试试这个
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//remove the row from data model
[tableData removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
我认为您的 TableView 可能会在您创建它并且方法结束后被释放。您可能需要在引用它的视图控制器中创建一个实例变量。
@property (strong, nonatomic) IBOutlet UITableView *tablview;
然后从 Table 视图中删除关联的单元格
[self.tablview deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
可能对你有帮助..
我的代码是:
- (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 核心基础 0x000000010d738f35 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010d3d1bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010d74004d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 核心基础 0x000000010d69827c ___forwarding___ + 988 4 核心基础 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 发送事件:] + 683 11 UIKit 0x000000010db399b1 -[UIApplication sendEvent:] + 246 12 UIKit 0x000000010db46a7d _UIApplicationHandleEventFromQueueEvent + 17370 13 UIKit 0x000000010db22103 _UIApplicationHandleEventQueue + 1961 14 核心基础 0x000000010d66e551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 15 核心基础 0x000000010d66441d __CFRunLoopDoSources0 + 269 16 核心基础 0x000000010d663a54 __CFRunLoopRun + 868 17 核心基础 0x000000010d663486 CFRunLoopRunSpecific + 470 18 图形服务 0x0000000110d079f0 GSEventRunModal + 161 19 UIKit 0x000000010db25420 UIApplicationMain + 1282 20 简单表 0x000000010cea27d3 主 + 115 21 libdyld.dylib 0x000000010fcc8145 开始 + 1 ) libc++abi.dylib:以 NSException 类型的未捕获异常终止 (lldb)
试试这个
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//remove the row from data model
[tableData removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
我认为您的 TableView 可能会在您创建它并且方法结束后被释放。您可能需要在引用它的视图控制器中创建一个实例变量。
@property (strong, nonatomic) IBOutlet UITableView *tablview;
然后从 Table 视图中删除关联的单元格
[self.tablview deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
可能对你有帮助..