My application's structure looks like:
UIViewController1
- UIViewController2 - Add UIView programmatically
UIViewController1 contains UIViewController2, and I add some UIView, loading from Xib, to the UIViewController2 with the following code:
SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject]; [self.view addSubview:b]; //- set Frame before or after addSubView, there is no difference CGRect frame = b.frame; frame.origin.x = 0; frame.origin.y = 0; b.frame = frame;
The original UIView looks like this:
After adding to the UIViewController, it looks like this:
With the following code, when I assign the width and height of the UIView equal to a part of the width and height of the main view, it looks good
SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject];
[self.view addSubview:b];
CGRect frame = b.frame;
frame.origin.x = 0;
frame.origin.y = 0;
//------- Assign the Width and Height Value
//-------------------------------------------
frame.size.width = CGRectGetWidth(self.view.bounds) / 3;
frame.size.height = CGRectGetHeight(self.view.bounds) / 3;
b.frame = frame;


