我有我的可用数据填充numberOfRowsInSection
内的当前部分。然后我希望它调用cellForRowAtIndexPath
,以便我可以使用这些数据。我在numberOfRowsInSection
我覆盖了上一节的数据。做NSLog
它显示numberOfRowsInSection
运行的第一个cellForRowAtIndexPath
之前的所有149个部分...为什么?iOS:cellForRowAtIndexPath不会在numberOfRowsInSection后立即调用
我已经删除了调用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
}
@jostster为什么这会对您的应用程序有所帮助? – bneely 2012-02-23 17:17:44
你所描述的听起来很奇怪。首先,你不应该在'numberOfRowsInSection'中覆盖任何东西。它应该只返回一个整数。可能需要更准确的细节。但我相信,一旦UITableView将这些委托方法踢掉,它就打算更新其视图中的某些内容。但它应该只是询问可见的部分和行。 – Jim 2012-02-23 17:20:10
@Jim我修改了我的OP来显示我在做什么。 – Bot 2012-02-23 17:22:51