如何旋转两个 UIView?
我使用 iOS 4.1 SDK 创建了一个应用程序。
在此应用程序中,我执行了以下操作:我将两个 UIView 作为子视图添加到应用程序的窗口中。一个视图是导航控制器视图,另一个视图是显示广告的视图。然后,用户可以在应用程序中导航,广告将不间断地显示。
现在问题来了:我想添加将设备从纵向旋转到横向并返回的选项。问题只是第一个视图(在我的例子中是导航控制器视图)旋转没有问题。第二个视图永远不会旋转。 Apple 的文档确认这是默认行为。
那么,如何旋转第二个视图呢?我需要重组我的申请吗?为什么第二个视图从不旋转?这对我来说没有任何意义。
I created a app with the iOS 4.1 SDK.
In this app I did the following: I add two UIView's as subview to the Window of the Application. One view is a navigationcontrollerview and the other is a view that displays advertisement. The user can then navigate trough the app will the ads are displayed uninterrupted.
Now comes the problem: I wanted to add the option to rotate the device from portrait to landscape and back. The problem is only the first view (in my case the navigationcontrollerview) is rotated without problem. The second view is never rotated. Documentation from Apple confirms that this is the default behavior.
So, how do I get my second view rotated? Do I need to restructure my application? And why is the second view never rotated? That doesn't make any sense to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否只是将第二个视图(不旋转的视图)添加为普通 UIView?如果是这样,请尝试将其包含在 UIViewController 类中后添加。不久前我的应用程序也遇到了同样的问题。我没有使用 [window addSubview:sampleView],而是 [window addSubview:[sampleViewController view]];其中sampleViewController是UIViewController的子类。
一般来说,始终使用相应的视图控制器并在其中包含视图,然后添加子视图以避免这些问题。
Are you just adding the second view (the one that doesn't rotate) as a plain UIView? If so, try adding it after containing it within a UIViewController class. I had the same issue in my app not so long ago. instead of [window addSubview:sampleView], I did [window addSubview:[sampleViewController view]]; where sampleViewController subclasses UIViewController.
In general, always use corresponding view controllers and contain views in them and then add subviews to avoid these issues.