我正在调用一个方法,在视图加载时选择表视图的第一行。但由于某种原因,在拨打selectFirstRow
之后,它会回到self.couldNotLoadData = NO
并继续往返。任何想法为什么?当最初的if/else循环转到else时,该方法不会被调用,因此它不会循环。为什么我用我的UITableView无限循环?
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
if (self.ichronoAppointments.count > 0)
{
self.couldNotLoadData = NO;
[self selectFirstRow];
return self.ichronoAppointments.count;
}
else
{
self.couldNotLoadData = YES;
return 1;
}
}
-(void)selectFirstRow
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionTop];
}