iphone - NSInvalidArgumentException与UITableView吗?

我正在为类制作一些信息指南。我需要使用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/

相关文章:

compiler-errors - 这怎么了? Submit.CommandText = SQL?

c++ - C++如何向minGW添加库

c++ - 无法解析的外部符号C++-错误的声明?

Excel VBA 错误 - 函数或接口(interface)标记为受限。或函数使用 Visual

android - NDK错误: “can' t resolve `.data.rel.ro.loc

java - Java : Longest Ascending substring

java - 升序子字符串编译错误

qt - 无法运行编译qt应用程序。 Qt Creator忽略斜线

c++ - OpenCV无法编译

scala - 斯卡拉(Scala),卡斯巴(Casbah): MongoCollection.in