IOS - Best Way to Style UITableView Cell With Interface Builder -


hey have read number of tutorials , articles on styling cells. due fact styling capabilities of interface builder limited have been forced research other methods , left conflicting feelings when trying find proper way programatically style uitableviewcell created in interface builder. of sources style cells directly in cellforrowatindexpath others suggest doing in .m uitableviewcell class. ran performance issues when styling in cellforrowatindexpath styling in classes .m file. here code styles:

- (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier {     self = [super initwithstyle:style reuseidentifier:reuseidentifier];      if (self)     {         nslog(@"test!");          _namelabel.font = [uifont fontwithname:@"gotham light" size:16];         _locationlabel.font = [uifont fontwithname:@"gotham light" size:14];         _titlelabel.font = [uifont fontwithname:@"gotham light" size:12];          [_thumbnailuserimage.layer setcornerradius:24];         [_thumbnailuserimage.layer setborderwidth:2];         [_thumbnailuserimage.layer setbordercolor:[[uicolor whitecolor] cgcolor]];         [_thumbnailuserimage.layer setmaskstobounds:yes];         self.contentview.backgroundcolor = [uicolor colorwithred:(247/255.0) green:(245/255.0) blue:(242/255.0) alpha:1];     }      return self; } 

here create each cellforrowatindexpath:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     user *user;     contactscell *cell = [[contactscell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:nil];     cell = (contactscell *)[tableview dequeuereusablecellwithidentifier:@"contactscell"];     user = [users objectatindex:indexpath.row];      if (cell == nil)     {         nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"contactscell" owner:self options:nil];         cell = [nib objectatindex:0];     }      cell.namelabel.text = [nsstring stringwithformat: @"%@ %@", user.firstname, user.lastname];     cell.titlelabel.text = [nsstring stringwithformat:@"%@", user.position];     cell.locationlabel.text = [nsstring stringwithformat:@"%@", user.location];      [cell.thumbnailimageview setimagewithurl:[nsurl urlwithstring: user.profileurl] placeholderimage:[uiimage imagenamed:@"stockprofilephoto.png"]];      return cell; } 

now reason above code does not work, have been successful styling cells directly in cellforrowatindexpath delegate method. wondering before try solve issue, should putting cell styles use <quartzcore/quartzcore.h> , other libraries can't edited interface builder? if correct answer 1 working on, how come styles aren't showing up? "test!" appears every created cell know the initwithstyle method has been overwritten , executing.

if doing in interface builder can't use initwithstyle. use awakefromnib instead.

override custom uitableviewcell


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -