xib中上面拖的控件为什么程序执行的时候看不到啊,view设置的背景色也没用?
本帖最后由 gscool 于 2012-11-21 08:12:28 编辑 我在storyboard中有一个ViewController(暂且命名为FVc),这个上面我用到了两个view,这两个view我定义了两个UIViewController,并且这两个UIViewController与xib文件进行了关联,这两个UIViewController暂且命名为AVc和BVc,我在Avc和BVc对应的xib中,在view上都增加了几个UILable,然后在FVc的viewDidLoad方法中把AVc和BVc中的view作为subview增加了,但是运行的时候AVc中的控件能现实,BVc中的就不显示,这是怎么回事?
部分代码如下,望大神指教啊!
FVc:
- (void)viewDidLoad
{
[super viewDidLoad];
if(AVc == nil)
{
AVc = [[AVCViewController alloc]init];
}
[self.view addSubview:AVc.view];
if(BVc == nil)
{
BVc = [[BVCViewController alloc]init];
}
[self.view addSubview:BVc.view];
}
-(id)init
{
if(self = [super init])
{
self.view.backgroundColor = [UIColor brownColor];
//NSLog(@"frame.width=%f frame.height=%f",self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = CGRectMake(0,0,200,self.view.frame.size.height);
}
}
-(id)init
{
if(self = [super init])
{
self.view.backgroundColor = [UIColor brownColor]; //这句如果加上的话能改变颜色,但是如果去掉直接在xib中给view的颜色改变一下,就看不到
//NSLog(@"frame.width=%f frame.height=%f",self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = CGRectMake(201,0,self.view.frame.size.width - 1,self.view.frame.size.height);
}
return self;
}