ios - Prototype UITableViewCell initialization -


earlier creating custom cells without prototype, custom class, register class reuse identifier uitableview , use that.

in case, used: - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier , worked great (except uitableviewheaderfooterview, never knew frame though method called, frame 0 0 0 0 - that's not question here).

now creating custom uitableviewcells using interface builder. created custom class, connected outlets interface builder custom class , i'v noticed - (id)initwithcoder:(nscoder *)adecoder being called , that's need modifications. but, wasn't able. that's init method being called, if try change font of label there, wont changed. tried round rect button not working (my button having frame 0 0 0 0 - not yet existing) in method.

my question is, should modify things font, background color of elements created using prototype cells?

(id)initwithcoder:(nscoder *)adecoder correct initializer.

try this:

@implementation testcell  - (id)initwithcoder:(nscoder *)adecoder {     self = [super initwithcoder:adecoder];     if (self) {         self.textlabel.font = [uifont boldsystemfontofsize:25.0f];     }     return self; }  @end 

other customizations (of own subviews) goes to:

- (void) awakefromnib {     [self.mybutton settitle:@"hurray" forstate:uicontrolstatenormal]; } 

it works fine. of course, have set identifier of cell in storyboard or interface builder file same identifier use in uitableviewcontroller.

i use piece of code in uitableviewcontroller:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"testcell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];     cell.textlabel.text = @"test";     return cell; } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -