I have a subclass of UIView that needs to calculates it\'s height according to it\'s width. When created in code everything works. However when I try to create the view in I
If you extend initWithCoder
, be sure to call the super method. It is during this super call that setFrame
will be called on your class.
You can then re-use your standard initWithFrame
call.
I always do the following:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder]; // Required. setFrame will be called during this method.
return [self initWithFrame:[self frame]];
}