重新加载noOfRowsInSection当表视图重新加载,xcode
问题描述:
我有问题,在显示当前位置时显示当前位置和当不显示当前视图时,在表视图中设置noOfRowsInSection,似乎当我设置当前位置的当前位置“行自动插入到表格视图中,并调整noOfRowsInSection中的行数(即时统计地图中没有任何行的注释的数量),我通过在用户连接时简单地增加no来解决问题到互联网,我的代码:重新加载noOfRowsInSection当表视图重新加载,xcode
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
int countval=[[map annotations] count];
Reachability *reach=[[Reachability reachabilityForInternetConnection] retain];
NetworkStatus status = [reach currentReachabilityStatus];
if (searching)
{
return [copyListOfItems count];
}
else {
if([[self stringFromStatus:status] isEqualToString:@"Connected via wifi"] || [[self stringFromStatus:status] isEqualToString:@"Connected via WWAN"])
{
return countval+1;//
}
else
{
return countval;
}
}
}
但是,现在即时通讯有问题,同时使用重载
表10[self.tableView reloadData];
numberOfRowsInSection得到刷新和再次混淆,我怎么能在刷新时再次设置numberOfRowsInSection,或者有另一种方法来解决这个问题,我会非常感激和感谢任何建议,代码,教程。请多关照
答
发现问题,重装表视图 当我的代码:
return countval+1;
只是不断加入1〜numberOfRowsInSection所以它给你排列出界错误,我固定通过简单的推杆常数87是我地图上注释的计数,不是最好的解决方案,但是由于我的注释计数是固定的,所以它解决了问题。
return 87;