将指定视图设置为横向模式时出现问题
我确实寻找可能的答案,但没有找到。我的问题是,我只希望应用程序中的一个视图(显示图像)同时处于纵向和横向模式,而其他视图仅处于纵向模式。
该视图作为其子视图添加到 [[[UIApplication sharedApplication] delegate] window]
中。
我在 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
和 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
在 - (void)viewDidLoad
中
,但是当我转动设备时,视图不会旋转。请告诉我哪里做错了或者还需要做什么。
I did look for possible answers but found none. my problem is that I only want one of the views in my app (which shows an image) to be in both portrait and landscape mode, while other views in portrait only.
this view is added to [[[UIApplication sharedApplication] delegate] window]
as its subview.
and i set return YES in - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
and also [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
in - (void)viewDidLoad
but when i turn the device the view doesn't rotate. please tell me where i did wrong or what more needs to be done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,子视图(例如您添加的子视图)仅在所属容器视图传递该消息时才会发送一条消息,表示设备已旋转。如果您使用 UINavigationController 或 UITabBar 并将视图添加到其中,那么它就已经为您完成了,但是如果您将视图直接添加到窗口中,那么它就不是了。
编辑:您可以使用 UIDeviceOrientationDidChangeNotification 与 NSNotificationCenter。
As far as I know, a subview (such as the one you added) is only sent the message saying the device has rotated if the owning container view passes it along. If you use a UINavigationController or UITabBar and add your view to that it is done for you, but if you add the view directly to the window as you have it isn't.
EDIT: you can capture the device orientation changing yourself using UIDeviceOrientationDidChangeNotification with NSNotificationCenter.