如果addsubview是横向完成的,视图不是横向的? iPhone SDK

发布于 2024-09-07 19:31:13 字数 565 浏览 4 评论 0原文

您好,当我的应用程序处于横向状态时添加子视图时遇到问题。当视图加载时,它处于纵向模式,因此视图的一部分丢失,我可以在右侧看到主视图。如果我以纵向模式加载子视图,然后旋转 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

单调的奢华 2024-09-14 19:31:13
        [self.view addSubview:viewSpinner];
        viewSpinner.frame = self.view.frame;
        [viewSpinner setNeedsLayout];

这对我有用(Y)

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

This works for me (Y)

对你而言 2024-09-14 19:31:13

尝试设置子视图的框架

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

try to set the frame of the subview

[screen.view setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
一场春暖 2024-09-14 19:31:13

您是否使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文