I'm begier in Objective-C. When i use addSubview in method setupView to see image, this doesn't work. Please, help.
h.
@interface CollectionViewController : UICollectionViewController
@end
@interface MyCell : UICollectionViewCell
@end
and
m.
@interface MyCell ()
@end
@implementation MyCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) [self setupView];
retu self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) [self setupView];
retu self;
}
-(UIImageView *)myImageView {
UIImageView *imageView = [UIImageView new];
imageView.image = [UIImage imageNamed:@"photo.jpg"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.layer.masksToBounds = true;
retu imageView;
}
-(void)setupView {
self.backgroundColor = [UIColor whiteColor];
[self addSubview:self.myImageView];
}
@end
