How can I add a subView to a custom UITableViewCell from the implementation file, i.e. MyCustomCell.m inside the drawRect method? Instead of adding it inside the cellForRowAtIndexPath method in the view controller …
I tried [self.contentView addSubView: view1]; but it gives this warning: UIView may not respond to -addSubView:
EDIT:
The code that caused the crash is :
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// Initialization code (add your view here.)
[self.contentView addSubView: self.view1];
}
return self;
}
it’s your misspelling; not
addSubView:, butaddSubview:.