uitableview - custom UITableViewCell subclass not able to get properties assigned -


i trying build image picker through alassets library , have table view albums when click on album view photos, in dynamic uitableviewcontroller composed of custom uitableviewcells doesnt allow me assign properties custom albumcontenttableviewcells...

both cell.rownumber & indexpath.row nsintegers complaining unrecognized selector...

// customize appearance of table view cells. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {  albumcontentstableviewcell *cell = [[albumcontentstableviewcell alloc] init];  cell = (albumcontentstableviewcell*)[tableview dequeuereusablecellwithidentifier:@"photo"];  cell.rownumber = indexpath.row; cell.selectiondelegate = self;  // configure cell... nsuinteger firstphotoincell = indexpath.row * 4; nsuinteger lastphotoincell  = firstphotoincell + 4;  if (assets.count <= firstphotoincell) {     nslog(@"we out of range, asking start photo %d have %d", firstphotoincell, assets.count);     return nil; }  nsuinteger currentphotoindex = 0; nsuinteger lastphotoindex = min(lastphotoincell, assets.count); ( ; firstphotoincell + currentphotoindex < lastphotoindex ; currentphotoindex++) {      alasset *asset = [assets objectatindex:firstphotoincell + currentphotoindex];     cgimageref thumbnailimageref = [asset thumbnail];     uiimage *thumbnail = [uiimage imagewithcgimage:thumbnailimageref];      switch (currentphotoindex) {         case 0:             [cell photo1].image = thumbnail;             break;         case 1:             [cell photo2].image = thumbnail;             break;         case 2:             [cell photo3].image = thumbnail;             break;         case 3:             [cell photo4].image = thumbnail;             break;         default:             break;     } }  return cell; 

}

i error when try assign custom uitablecell 'rownumber' property:

'nsinvalidargumentexception', reason: '-[uitableviewcell setrownumber:]: unrecognized selector sent instance 0x1e2a43a0'

albumcontentstableviewcell.h

#import <uikit/uikit.h>  #import "thumbnailimageview.h"  @class albumcontentstableviewcell;  @protocol albumcontentstableviewcellselectiondelegate <nsobject> - (void)albumcontentstableviewcell:(albumcontentstableviewcell *)cell selectedphotoatindex:(nsuinteger)index; @end  @interface albumcontentstableviewcell : uitableviewcell <thumbnailimageviewselectiondelegate> {  iboutlet thumbnailimageview *photo1; iboutlet thumbnailimageview *photo2; iboutlet thumbnailimageview *photo3; iboutlet thumbnailimageview *photo4;  nsinteger rownumber; //id <albumcontentstableviewcellselectiondelegate> selectiondelegate; }  @property (nonatomic) nsinteger rownumber; @property (nonatomic, weak) id<albumcontentstableviewcellselectiondelegate> selectiondelegate;  - (uiimageview *)photo1; - (uiimageview *)photo2; - (uiimageview *)photo3; - (uiimageview *)photo4;  - (void)clearselection; @end 

albumcontentstableviewcell.m

#import "albumcontentstableviewcell.h" #import "thumbnailimageview.h"  @implementation albumcontentstableviewcell  @synthesize rownumber; @synthesize selectiondelegate; 

story board

story board

 #import <uikit/uikit.h>  @class thumbnailimageview;  @protocol thumbnailimageviewselectiondelegate <nsobject> - (void)thumbnailimageviewwasselected:(thumbnailimageview *)thumbnailimageview; @end  @interface thumbnailimageview : uiimageview {  uiimageview *highlightview; id <thumbnailimageviewselectiondelegate> delegate; }  @property(nonatomic, assign) id<thumbnailimageviewselectiondelegate> delegate;  - (void)clearselection; @end 

it looks when calling

[tableview dequeuereusablecellwithidentifier:@"photo"]; 

it dequeuing uitableviewcell , not albumcontentstableviewcell. since uitableviewcell not have setrownumber: selector throwing exception. need allocating , initing albumcontentstableviewcells somewhere.

edit:
need register albumcontentstableviewcell use @"photo" identifier. try adding `viewdidload' method:

    [self.tableview registerclass:[albumcontentstableviewcell class] forcellreuseidentifier:@"photo"]; 

note haven't tested code out, think close need.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -