我正在为类制作一些信息指南。我需要使用UITableView,少了一些看起来像废话的东西,所以我已经做了大约一个星期。
我收到的错误是以下代码中的NSInvalidArgumentException:
- (NSInteger)numberOfRowsInSection:(NSInteger)section{
/*NSDictionary *dict = [_allPerks objectAtIndex:section];
NSArray *temp = [dict objectForKey:@"Perks"];
return [temp count];*/
if (section == 0)
return 9;
else if (section ==1)
return 7;
else if (section ==2)
return 11;
else if (section == 3)
return 11;
else if (section == 4)
return 8;
else
return 0;
}
最佳答案
试试这个代码
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0){
return 9;
}
else if (section ==1){
return 7;
}
else if (section ==2){
return 11;
}
else if (section == 3){
return 11;
}
else if (section == 4){
return 8;
}
else{
return 0;
}
}
https://stackoverflow.com/questions/15395512/