2012-03-01 199 views
0

我有問題,在顯示當前位置時顯示當前位置和當不顯示當前視圖時,在表視圖中設置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,或者有另一種方法來解決這個問題,我會非常感激和感謝任何建議,代碼,教程。請多關照

回答

0

發現問題,重裝表視圖 當我的代碼:

return countval+1; 

只是不斷加入1〜numberOfRowsInSection所以它給你排列出界錯誤,我固定通過簡單的推杆常數87是我地圖上註釋的計數,不是最好的解決方案,但是由於我的註釋計數是固定的,所以它解決了問題。

return 87;