我正在調用一個方法,在視圖加載時選擇表視圖的第一行。但由於某種原因,在撥打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];
}