如果addsubview是横向完成的,视图不是横向的? iPhone SDK
您好,当我的应用程序处于横向状态时添加子视图时遇到问题。当视图加载时,它处于纵向模式,因此视图的一部分丢失,我可以在右侧看到主视图。如果我以纵向模式加载子视图,然后旋转 iPhone,它会旋转到横向模式,没有问题。我用谷歌搜索了很多,这似乎是一个常见问题,但我无法找到解决方案。请问有人可以帮忙吗?
这是我添加视图的代码...
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 commitAnimations];
谢谢:-)
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 commitAnimations];
Thanks :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这对我有用(Y)
This works for me (Y)
尝试设置子视图的框架
try to set the frame of the subview
您是否使用 xib 创建首选项视图控制器?不要忘记将父视图设置为自动调整其子视图的大小,并设置子视图的自动调整大小掩码,以便其父视图可以适当地自动调整其高度和宽度。
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.