【发布时间】:2016-07-29 08:59:47
【问题描述】:
我在 tableview 中有两个部分位于 tableviewcontroller 内 由于某种原因,方法 numberOfRowsInSection 中的部分值始终为“1”。这很奇怪,因为一切似乎都很好。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
int i=section;
if(section==0)
return 1;
else{
return [self.flightDetailsArray count];
}
}
在情节提要中,我有一个包含两个部分的表格
好的,再次为您理解问题。看这段代码
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
NSLog(@"Section: %d",(int)section);
if(section==0)
return 1;
else{
return [self.flightDetailsArray count];
}
}
在日志中我总是看到“1” 那是什么?很奇怪
【问题讨论】:
-
这很不寻常。你能证明你怎么知道它永远不是
0吗? -
我使用调试器。我什至可以记录它。但无论如何它总是“1”
-
我怀疑情况是否如此,所以请您提供更多证据,以便我们查看您是否在调查中遗漏了什么。
-
我可以提供故事板屏幕,还要注意它是一个 UITableViewController
-
我会尝试重新创建这些部分,可能是 xcode 的一些错误。我试图清理项目,没有帮助。
标签: ios xcode uitableview