viewWillT出現以下內
容 [SYPTableView setSeparatorInset:UIEdgeInsetsZero];
在iOS 7上运行良好,但在6.1上它引发了异常:
NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance
我的目的是删除单元格边框。
separatorInset
属性在 iOS 7.0 的UITableView
上可用,这就是您在 iOS 6.1 上出现异常的原因。
从您发布的代码来看,您似乎要删除iOS 7中引入的默认插图。iOS 6中不存在此类插图,因此您只需在iOS 7中删除插图即可。
您可以检查表视图是否响应setSeparatorInset:
执行
if ([SVPTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[SYPTableView setSeparatorInset:UIEdgeInsetsZero];
}
如果您正在使用ios 6等,请使用以下内容
SEL selector;
selector=NSSelectorFromString(@"setSeparatorInset:");
if([table respondsToSelector:selector])
{
@try {
dispatch_async(dispatch_get_main_queue(), ^{
NSMethodSignature *aSignature;
NSInvocation *anInvocation;
aSignature=[table methodSignatureForSelector:selector];
anInvocation=[NSInvocation invocationWithMethodSignature:aSignature];
[anInvocation setSelector:selector];
[anInvocation setTarget:table];
UIEdgeInsets temp=UIEdgeInsetsZero;
[anInvocation setArgument:&temp atIndex:2];
[anInvocation invoke];
});
}
@catch (NSException *exception) {
NSLog(@"EXCEPTION WHILE CALLING Separator inset => %@",[exception userInfo]);
}
@finally {
}
}