iOS程序-使用xib的owner

时间:2015-12-17 19:02:22   收藏:0   阅读:199

1.添加绿色的view,MJViewController对象作为owner

    NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];    

    UIView *greenView = array[0];

    [self.view addSubview:greenView];

2.添加蓝色的view,Dog对象作为owner

    UIView *blueView = [[NSBundle mainBundle] loadNibNamed:@"HisView" owner:_d2 options:nil][0];

    blueView.center = CGPointMake(160, 200);

    [self.view addSubview:blueView];

3.owner的机制为代理模式

方法/步骤

原文:http://www.cnblogs.com/ChouDanDan/p/5054960.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!