php - iOS - UITableView - numRowsInSection differs to cellForRowAtIndexPath -
i'm having little trouble uitableview. i'm loading tableview json returned our server.
json link pastebin >
(i've removed items readability contained hundreds) print_r() output php.
as can see it's using sub arrays. when log sections , counts numberofrowsinsection, correct.
eg,
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if([tableview isequal: self.timetabletableview]){ nsdictionary *sectioncontents = [_timetabledataarray objectatindex: section]; nslog(@"section: %d, count: %d", section, [sectioncontents count]); return [sectioncontents count]; } return 0; }
returns,
section: 6, count: 12 section: 0, count: 35 section: 1, count: 35 section: 2, count: 38 section: 3, count: 33 section: 4, count: 19 section: 5, count: 15
so far good. table view draws correct amount of sections , cells, per section.
now, problem in cellforrowatindexpath. it's not being called amount of times i'd expect. i'm not sure i'm doing wrong.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if([tableview isequal: self.timetabletableview]){ static nsstring *timetablecellidentifier = @"timetabletablecell"; timetabletablecell *cell = (timetabletablecell *)[tableview dequeuereusablecellwithidentifier:timetablecellidentifier]; if(cell == nil){ nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"timetabletablecell" owner:self options:nil]; cell = [nib objectatindex:0]; } // day array out of json. nsdictionary *daycontents = [_timetabledataarray objectatindex:indexpath.section]; nslog(@"row: %d, path: %d", indexpath.row, indexpath.section); return cell; } }
this logs,
row: 0, path: 0 row: 1, path: 0 row: 2, path: 0 row: 3, path: 0 row: 4, path: 0 row: 5, path: 0 numberofsectionsintableview returns correct amount of sections. - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { if([tableview isequal: self.timetabletableview]){ nslog(@"sections: %d", [_timetabledataarray count]); return [_timetabledataarray count]; } return 0; } sections: 7
as far can tell, cellforrowatindexpath iterating on days array in json . although has correct amount of sections/cells in numberofrowsinsection.
how can tell cellforrowatindexpath iterate on days array (section) contents?
is possible loop through sub arrays uitableviews?
any appreciated! thanks, adrian
this no error. cellforrowatindexpath
called "on demand" visible cells. when scroll down, called remaining cells.
Comments
Post a Comment