iphone - Calling two different custom cell in one UITableView issue -


i have created custom cell featurecell has 5 images in row called in main view when call empty row. please problem?

i have googled custom cell , used way have use in code below nothing happen.

this featurecell.h

@interface featurecell : uitableviewcell{    iboutlet uiimageview *img1;   iboutlet uiimageview *img2; }  @property (nonatomic, retain) uiimageview *img1; @property (nonatomic, retain) uiimageview *img2; @end 

this featurecell.m

@implementation featurecell  @synthesize img,img1,img2,img3,img4; @end 

this view-controller .m

- (nsinteger) numberofsectionsintableview:(uitableview *)tableview{  return 2; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{  if (section == 0) {     return [objectcollection count]; } else{     return 1;    } }      - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  static nsstring* cellidentifier1 = @"featurecell";  featurecell *cell1 = (featurecell*)[tableview dequeuereusablecellwithidentifier:cellidentifier1];   if (cell1 == nil) {     nsarray *nib = [[nsbundle mainbundle] loadnibnamed:cellidentifier1 owner:nil options:nil];      cell1 = (featurecell*)[nib objectatindex:0]; }  static nsstring *cellidentifier = @"cell";  uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];   if (cell == nil) {     cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1                                   reuseidentifier:cellidentifier];  }   if ([indexpath section] == 0) {      containerobject = [objectcollection objectatindex:indexpath.row];      [[cell textlabel] settext:containerobject.store];      cell.selectionstyle = uitableviewcellselectionstylenone;  }     else{      cell1.img1.image = [uiimage imagenamed:@"shower.png"];     cell1.img2.image = [uiimage imagenamed:@"parking.png"];      }         return cell; } 

you need this:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     if (indexpath.section == 0) {         static nsstring *cellidentifier = @"cell";          uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];         if (cell == nil) {             cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylevalue1                               reuseidentifier:cellidentifier];         }          containerobject = [objectcollection objectatindex:indexpath.row];         [[cell textlabel] settext:containerobject.store];         cell.selectionstyle = uitableviewcellselectionstylenone;          return cell;     } else {         static nsstring* cellidentifier1 = @"featurecell";          featurecell *cell1 = (featurecell*)[tableview dequeuereusablecellwithidentifier:cellidentifier1];         if (cell1 == nil) {             nsarray *nib = [[nsbundle mainbundle] loadnibnamed:cellidentifier1 owner:nil options:nil];             cell1 = (featurecell*)[nib objectatindex:0];         }          cell1.img1.image = [uiimage imagenamed:@"shower.png"];         cell1.img2.image = [uiimage imagenamed:@"parking.png"];          return cell1;     } } 

i might have if condition backwards double check that.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -