I searched, but cannot find the answer to this question that I have. This seems pretty fundamental, so hopefully someone can explain or point me to a previous post.
When I add a view to the viewcontroller as a subtitle of another view manager, I find that the subexpression height property vanishes during rotation. Width is also increasing.
For example, if the NSDChildViewController view is set to 50x100 in the xib file ...
@implementation ParentViewController
-(void)viewDidLoad
{
[super viewDidLoad];
mChild = [[ChildViewController alloc] initWithNibName:nil
bundle:nil];
[self.view addSubview:mChild.view];
}
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[mChild printFrame];
}
@end
@implementation ChildViewController
-(void)printFrame
{
NSLog(@"%s %@",__FUNCTION__, NSStringFromCGRect(self.view.frame));
}
@end
The record for orientation orientation portrait-> landscape-> portrait is as follows:
- [PictureFrame ChildViewController] {{0, 0}, {50, 100}}
- [PictureFrame ChildViewController] {{0, 0}, {298, 0}}
- [PictureFrame ChildViewController] {{0, 0}, {50, 248}}
? . , , - 50x100, - ...
-(void)forceSize
{
CGRect frame = self.view.frame;
frame.size.width=50;
frame.size.height=100;
self.view.frame=frame;
}
. .