开发者

View is not landscape if addsubview is done in landscape? iPhone SDK

Hi I have a problem when adding a subview when my app is in landscape. When the view gets loaded it is in portrait mode so part of the view is missing and I can see the main view on the right hand side. If I load the subview in portrait mode then rotate the iPhone it rotates to landscape no problem. I have googled this lots and it seems to be a common problem yet I am unable to find a solution. Please can someone help?

This is my code to add the view...

PreferencesViewController *screen = [[PreferencesViewController alloc]initWithNibName:nil bundle:nil];

[self.view addSubview:screen.view];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[UIView commitAn开发者_如何学Goimations];

Thanks :-)


        [self.view addSubview:viewSpinner];
        viewSpinner.frame = self.view.frame;
        [viewSpinner setNeedsLayout];

This works for me (Y)


try to set the frame of the subview

[screen.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];


Are you creating the preference views controller using a xib? Dont forget to set the parent view to auto resize its subviews, and set the child view's autoresizingmasks so its parent view can auto adjust its height and width appropriately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜