xib嵌套使用注意

http://www.tuicool.com/articles/ENv6Nf

 

// 被使用的xib需要重写此方法

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        
//        UIView *containerView = [[UINib nibWithNibName:@"SecondView" bundle:nil] instantiateWithOwner:self options:nil][0];
        
        UIView *containerView = [[NSBundle mainBundle] loadNibNamed:@"SecondView" owner:self options:nil][0];
        
        CGRect newFrame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        
        containerView.frame = newFrame;
        
        [self addSubview:containerView];
        
    }
    return self;
}

posted on 2015-03-26 17:05  JZLOY  阅读(159)  评论(0编辑  收藏  举报

导航