The functionality that I am trying to achieve is that first I am showing two rows in a UITableView which is showing perfectly. Then on didSelectRowAtIndexpath:, I am adding the numberOfRows in the UITableView, for which I am reloading the UITableView after adding the numberOfRows and the required data.
My problem is that I am passing the new number of rows in the numberOfRowsInSection: (which I have checked, it is passing correctly) but cellForRowAtIndexpath: is called only two times after that, which is the previous numberOfRows value.
My Code:
- (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];
}
What could be the reason?
Any help would be appreciated!!!
I found the solution.
As I was resizing my
UITableViewas per its number of rows incellForRowAtIndexPath:, that’s why the next part of theUITableViewwas not visible, and for the part of theUITableViewwhich is not visible,cellForRowAtIndexPath:is never called.Sorry to bother you all.
Thanks a lot for your help!!!