Saturday, September 28, 2013

xib control Why drag in the above program execution time can not see ah, view to set the background color is useless?

posts by gscool on 2012-11-21 08:12:28 Edit
I have a storyboard ViewController (for the time being named FVc), I used the above two view, these two view I defined two UIViewController, and the two UIViewController with xib files were correlated, these two UIViewController for the time being named AVc and BVc, I Avc and BVc corresponding xib, in the view have increased on several UILable, then FVc the viewDidLoad method to AVc and BVc of view as a subview increased, but when running AVc the controls can realistically, BVc in not show how this is going?
Part of the code is as follows, looking great God enlighten ah!
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];
}


AVc:
 
- (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);
}
}


BVc:
 
- (Id) init
{
if (self = [super init])
{
self.view.backgroundColor = [UIColor brownColor]; / / phrase if one adds the words change color, but if you take in to view directly in the xib change the color look, you do not see
/ / 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;
}


BVc.view this area are shown in the FVc.view color, the color does not show BVc.View and above UILable not displayed, AVc.view area on no problem.
Reply:
Their top, help ah
Reply:
Why storyboard it? 4.3 are not up and running
Reply:
If you use IBout what's statement, then you do not need to continue to go in ViewDIdLoad alloc and init a new class of.
You should ViewController init method, do some AddSubView operation.

I think the same category ViewController, you generate two times, that is, there are two in the same category ViewController, one identifies you to XIB, then ViewDidLoad the time, and there is no corresponding AddSUbView to your logo ViewController, but the identification ViewController to a new generation on.

No comments:

Post a Comment