Follow these steps: take the method that is the designated initializer for your view. That is, it is the most customizable (for example, the argument itself) init ... method, which calls every other initializer. For example, it could be -initWithFrame: as usual. Then execute this method as follows:
- (id) initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // add new views here, for example: UIImageView *imageView = [[UIImageView alloc] initWithImage:anImage]; [self addSubview:imageView]; [imageView release]; } return self; }
user529758
source share