我試圖實現的功能是,首先我在UITableView
中顯示兩行,顯示完美。然後在didSelectRowAtIndexpath:
上,我在UITableView
中加入numberOfRows
,爲此我在加入numberOfRows
和所需數據後重新加載UITableView
。cellForRowAtIndexPath不被調用所需的次數
我的問題是,我通過在numberOfRowsInSection:
行的新號碼(我已經檢查,它被正確地傳遞),但cellForRowAtIndexpath:
只有兩次後調用,這是以前numberOfRows
值。
我的代碼:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.currentSubCategoryRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// My code for cell construction goes here
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.arrWithAdditionalValues addObjectsFromArray:[self.dictSubCategoriesLevel3 objectForKey:[NSString stringWithFormat:@"%d",rowOpened]]];
self.currentSubCategoryRows += self.arrWithAdditionalValues.count;
[tableView reloadData];
}
可能是什麼原因?
任何幫助將不勝感激!
你能在這裏顯示代碼如何增加行數嗎? – 2012-07-11 05:32:48
請告訴我們代碼。 – AJS 2012-07-11 05:35:44
我已經使用代碼編輯了我的問題... – 2012-07-11 05:40:10