从xib中创建完毕后会调用awakeFromNib方法

#pragma mark - 生命周期方法
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initial];
    }
    return self;
}

- (id)init {
    if (self = [super init]) {
        [self initial];
    }
    return self;
}

#pragma mark 当MJScrollView从xib中创建完毕后会调用这个方法
- (void)awakeFromNib {
    [self initial];
}

- (void)dealloc {
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    // 注意:记得要移除
    [center removeObserver:self];
    [super dealloc];
}

猜你喜欢

转载自wo890532.iteye.com/blog/2169379