![](/img/trans.png)
[英]NSInvalidArgumentException reason : unrecognized selector sent to instance
[英]NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance
以下是viewWillAppear
[SYPTableView setSeparatorInset:UIEdgeInsetsZero];
在iOS 7上正常工作但在6.1上它引發了異常:
NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance
我的目的是刪除單元格邊框。
在iOS 7.0的UITableView
上可以使用separatorInset
屬性,這就是你在iOS 6.1上獲得異常的原因。
從您發布的代碼看起來您想要刪除iOS 7中引入的默認插入。這樣的插入在iOS 6中不存在,因此您只需要刪除iOS 7中的插入。
您可以檢查表視圖是否響應setSeparatorInset:
doing
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 {
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.