iphone - cellForRowAtIndexPath always return nil -
iphone - cellForRowAtIndexPath always return nil -
i have created sample application insert 12 rows in tableview.and inserted fine.when after inserted rows dont want changes in text during scrolling of tableview.so checked indexpath row has value of uitableviewcell , if has values means homecoming cell otherwise created new uitableviewcell.
my sample code below
- (nsinteger)numberofsectionsintableview:(uitableview *)tableview { homecoming 1; }
// customize number of rows in table view. - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { nslog(@"globalcount = %d",globalcount); homecoming globalcount; }
- (uitableviewcell *)tableview:(uitableview *)tv cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *obj = (uitableviewcell*)[tableview cellforrowatindexpath:indexpath]; if(obj!=nil) { nslog(@"cell indexpath row = %d",indexpath.row); nslog(@"cell text = %d",obj.textlabel.text); homecoming obj; } else { nslog(@"obj==nil"); } static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tv dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; cell.selectionstyle = uitableviewcellselectionstylenone; } if([datatable count]>0) cell.textlabel.text = [datatable objectatindex:0]; // configure cell. homecoming cell; }
what objective , dont want update text (or uitableviewcell)for created indexpath rows(of cell).so can check in cellforrowatindexpath , homecoming nil.if missing ?
i checked using line
uitableviewcell *obj = (uitableviewcell*)[tableview cellforrowatindexpath:indexpath]; if(obj!=nil) plz help me?
thanks in advance......
let table view decide id need update cell or not. remove firsdt part of code , run smoothly.
don't hesitate read uitableview doc.
iphone cocoa-touch uitableview
Comments
Post a Comment