I have rephrased my earlier question to get some experts attention :) Is there any difference in creating a custom view in interface builder over code.
If I create the custom view from interface builder, drawrect method is getting invoked, if I do it from code,drawrect is not getting invoked? Thanks Sasikumar Sent from my iPhone On Jan 16, 2013, at 9:47 PM, Sasikumar JP <jps...@gmail.com> wrote: > Hi, > I am working on a project, where i have to create horizontal tableview with > custom tableview cell. i am using AutoLayout constraints to layout all cell's > subview elements. > > Here is the my tableview cell init method, here i am using JPFilmBorderView > to draw some custom drawing. but JPFilmBorderView drawRect method never gets > invoked. > - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString > *)reuseIdentifier > > { > > NSLog(@"initwithstyle invoked"); > > self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; > > if (self) { > > JPFilmBorderView *topFilmBorderView = [[JPFilmBorderView alloc] > initWithFrame:CGRectZero]; > > topFilmBorderView.contentMode = UIViewContentModeRedraw; > > topFilmBorderView.backgroundColor = [UIColor whiteColor]; > > topFilmBorderView.translatesAutoresizingMaskIntoConstraints = NO; > > > > JPFilmBorderView *bottomFilmBorderView = [[JPFilmBorderView alloc] > initWithFrame:CGRectZero]; > > bottomFilmBorderView.translatesAutoresizingMaskIntoConstraints = NO; > > bottomFilmBorderView.backgroundColor = [UIColor greenColor]; > > > > self.thumbnailImage = [[UIImageView alloc] initWithFrame:CGRectZero]; > > _thumbnailImage.translatesAutoresizingMaskIntoConstraints = NO; > > > > [self.contentView addSubview:topFilmBorderView]; > > [self.contentView addSubview:_thumbnailImage]; > > [self.contentView addSubview:bottomFilmBorderView]; > > > > NSDictionary *viewDict = > NSDictionaryOfVariableBindings(_thumbnailImage, topFilmBorderView, > bottomFilmBorderView); > > [self.contentView addConstraints:[NSLayoutConstraint > constraintsWithVisualFormat:@"V:|[topFilmBorderView(20)]-[_thumbnailImage]-[bottomFilmBorderView(20)]|" > options:0 metrics:nil views:viewDict]]; > > [self.contentView addConstraints:[NSLayoutConstraint > constraintsWithVisualFormat:@"H:|[topFilmBorderView]" options:0 metrics:nil > views:viewDict]]; > > [self.contentView addConstraints:[NSLayoutConstraint > constraintsWithVisualFormat:@"H:|[_thumbnailImage]" options:0 metrics:nil > views:viewDict]]; > > [self.contentView addConstraints:[NSLayoutConstraint > constraintsWithVisualFormat:@"H:|[bottomFilmBorderView]" options:0 > metrics:nil views:viewDict]]; > > > > } > > return self; > > } > > Here is the JPFilmBorderView implementation.i never see the NSLog output from > drawRect method. > > ============================ > > @implementation JPFilmBorderView > > - (id)initWithFrame:(CGRect)frame > > { > > self = [super initWithFrame:frame]; > > if (self) { > > // Initialization code > > } > > return self; > > } > > - (void)drawRect:(CGRect)rect > > { > > NSLog(@"Rect %@",[NSValue valueWithCGRect:rect]); > > } > > I am observing this problem only if i define the custom view from program, > where as if i use storyboard/nib file, custom view drawRect method is getting > invoked. > > i am not sure what i am missing here. any help is highly appreciated. > > Thank you > > Sasikumar JP > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com