iphone - How to create custom UITableViewCell without using XIB -


i found many tutorials on how create custom table view cell using xib, possible create custom table view cell without using xib? can 1 me?

yeah, can create custom table view cell without using xib.

for this, have create 1 new class in xcode subclass of uitableviewcell. here can't select xib options.

now open custom uitableviewcell class , here's code achieve want:

#import "customcell.h"  @implementation customcell  @synthesize ivuser; @synthesize lblusername;  - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier: (nsstring *)reuseidentifier  {     self = [super initwithstyle:style reuseidentifier:reuseidentifier];       if (self) {            // initialization code          ivuser = [[uiimageview alloc] initwithframe:cgrectmake(4.0f, 3.0f, 39.0f,         38.0f)];         lblusername = [[uilabel alloc] initwithframe:cgrectmake(58.0f, 8.0f, 50.0f,         27.0f)];          [self.contentview addsubview:ivuser];         [self.contentview addsubview:lblusername];       }     return self; } 

now set subviews coordinates according requirement, use cell in cellforrowatindexpath , should work.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -