Bot*_*Bot 1 iphone objective-c uitableview ios5
我为我当前的部分填充了我的uitable数据numberOfRowsInSection.然后cellForRowAtIndexPath,我希望它可以调用,以便我可以使用该数据.
在我,numberOfRowsInSection我正在覆盖上一节中的数据.这样做NSLog表明numberOfRowsInSection在第一个之前cellForRowAtIndexPath调用了所有149个部分...为什么?
我已经删除了调用,reloadData因为我看到这是堆栈溢出的其他人的问题但是没有解决问题.
每个吉姆,我正在添加我正在做的事情.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSMutableArray *tempArray = [NSMutableArray array];
FMResultSet *appointmentResults = [[DataClass getDB] executeQuery:@"SELECT * FROM Appointments WHERE date = ?",[self.appointmentDates objectAtIndex:section]];
int rowCount = 0;
while ([appointmentResults next]) {
[tempArray addObject:[appointmentResults resultDict]];
rowCount++;
}
self.appointments = tempArray;
NSLog(@"Appointments: %@ - %i", [self.appointmentDates objectAtIndex:section], rowCount);
return rowCount;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Parse the appointments for the current section and display them
}
Run Code Online (Sandbox Code Playgroud)
从一般意义上讲,依靠Apple以任何特定模式调用您的委托函数并不是一种很好的做法.
特别是UITableView,它只会在需要知道的基础上请求数据.UITableView更需要知道整个表中有多少部分和行,以便它可以正确处理滚动位置和滚动条大小等内容,同时可以允许实际单元格内容滑动直到它们即将进入用户的观点.
您不能将numberOfRowsInSection调用为暗示系统想要知道某个部分中有多少行的内容.:)
| 归档时间: |
|
| 查看次数: |
3053 次 |
| 最近记录: |