ios - Custom cells not loading in tableview? -
i'm having strangest issue; know why below table view isn't loading custom cells? , yes, datasource , delegate connected view controller :) i've done before, of sudden it's missing.
.h
@interface myaccountviewcontroller : uiviewcontroller { iboutlet uitableview *storagetableview; nsarray *storeditems; nsmutabledata *data; }
.m
- (int)numberofsectionsintableview: (uitableview *)tableview { return 1; } - (int)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [storeditems count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *doctorstableidentifier = @"storageitemtableviewcell"; storageitemtableviewcell *cell = (storageitemtableviewcell *)[tableview dequeuereusablecellwithidentifier:doctorstableidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"storageitemtableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; nsdictionary *node = [storeditems objectatindex:indexpath.row]; [[cell itemname] settext:[node objectforkey:@"title"]]; [[cell itemdescrip] settext:[[[[node objectforkey:@"body"] objectatindex:0] objectforkey:@"raw"] objectforkey:@"value"]]; } return cell; } - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { return 99; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { }
one big problem setup each cell once. need change code to:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *doctorstableidentifier = @"storageitemtableviewcell"; storageitemtableviewcell *cell = (storageitemtableviewcell *)[tableview dequeuereusablecellwithidentifier:doctorstableidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"storageitemtableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; } cell.itemname.text = [[storeditems objectatindex:indexpath.row] objectforkey:@"name"]; cell.itemdescrip.text = [[storeditems objectatindex:indexpath.row] objectforkey:@"description"]; return cell; }
you need make sure [storeditems count]
returning non-zero value.
Comments
Post a Comment