1. [__NSCFConstantString count]: unrecognized selector sent to instance 0x10ce7f8c0
类型不匹配导致, 存储的是NSString,却用NSMutableArray接收,这个时候使用NSMutableArray属性的时候程序就会奔溃.
排错方法: 检查存储的数据类型是自己需要的类型, [xxx class]打印类型.
2. 首页滑动之后,collectionView不能点击(偶尔可以点击,偶尔不恩能够点击).头部不加东西没有问题,加了图片轮播和另一个就不能滑动✓解决方案:
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
PJLog(@"---你为什么会进来---%@", event);
3. UITableView 的cell有时候点击没有反应
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
错写成
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
只需要在 + (void)hideHUDForView:(UIView *)view 方法里面添加下面一句代码就可以解决
if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
5. 不要在子线程操作主线程的UI界面, 原因是: 有时候操作没有问题, 有时候有问题. 这样就会出现一些莫名其妙的问题.
NSArray *responseCount = responseObj;
if (responseCount.count) {
if ([[responseObjclass]isSubclassOfClass:[NSArrayclass]]) {
NSArray * dict = (NSArray*)responseObj;
if (dict.count==0) {
[self.homeGridDetailFrameremoveAllObjects];
[self.tableViewreloadData];
return;
}
}
if ([[responseObjclass]isSubclassOfClass:[NSDictionaryclass]]) {
NSDictionary * dict = (NSDictionary*)responseObj;
if ([STRING_FORMAT(dict[@"status"])isEqualToString:STRING_Int(0)]) {
[MBProgressHUDshowError:dict[@"mes"]];
[self.homeGridDetailFrameremoveAllObjects];
[self.tableViewreloadData];
return;
}
}
//数据转模型
NSArray *newFrames = [selfhomeGridDetailFrameWithOriginalData:responseObj];
self.homeGridDetailFrame = [newFramesmutableCopy];
[self.tableViewreloadData];
// 结束刷新
[MBProgressHUD hideHUD];
[self.tableView.mj_headerendRefreshing];
} else {
[self.homeGridDetailFrameremoveAllObjects];
[self.viewinsertSubview:self.labelHintbelowSubview:self.menu];
[self.tableViewreloadData];
}
这篇博客汇总了iOS开发中遇到的一些典型错误,包括类型不匹配导致的奔溃、collectionView点击失效、UITableView cell点击无响应以及主线程UI操作的问题,并提供了相应的排查和解决办法。
704

被折叠的 条评论
为什么被折叠?



