UIDEVICE方向
大家好,我有我的启动屏幕,我想以横向模式显示它,并以纵向模式显示所有其他屏幕。我的根视图控制器充当启动屏幕,我正在 viewdidload 方法中编写此代码,
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
但此代码不起作用,并显示 UIdevice 可能不会响应 setorentation 请指导我如何更改仅第一个启动屏幕的方向和其他屏幕也应处于肖像模式
hello all i have my splash screen which i want to show in landscape mode and all other screen in potrait mode. My root view controller is acting as a splash screen i am writing this code in viewdidload method
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
But this code is not working and shows me that UIdevice may not respond to setorentation please guide me that how could i change the orentation for only first splash screen and also other screen should be in potrait mode
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIDeviceOrientation
是指设备的物理方向,而UIInterfaceOrientation
是指用户界面的方向。您无法更改设备的物理方向,但可以通过[UIApplication sharedApplication].statusBarOrientation
更改状态栏的显示方式UIDeviceOrientation
refers to the physical orientation of the device whereasUIInterfaceOrientation
refers to the orientation of the user interface. You can't change the physical orientation of the device, but you can change how the status bar is displayed via[UIApplication sharedApplication].statusBarOrientation
不能只让一个闪屏横向显示吗?
用户会将其解释为“横向”飞溅并进行相应调整,无论您的应用程序是否确实认为如此。只需确保在
shouldAutorotateToInterfaceOrientation:
中返回NO
,这样当用户转动它时它就不会旋转。但警告:可能值得调整您的启动屏幕,使其处于纵向方向,因为向用户建议您的应用程序喜欢横向,然后尽快切换到纵向可能会很烦人因为它实际上开始了。
不过,如果您确实愿意,可以使用 setStatusBarOrientation:animated: 在
UIApplication
上强制方向。Can't you just have a splash screen that is displayed sideways?
The user will interpret that as a "landscape" splash and adjust accordingly, whether or not your application actually thinks it is. Just make sure to return
NO
inshouldAutorotateToInterfaceOrientation:
so it doesn't rotate away when the user turns it.But a warning: it's probably worthwhile to tweak your splash screen so it is in the portrait orientation, since it may be annoying to suggest to the user that your app likes landscape, and then switch to portrait as soon as it actually starts.
If you really want to, though, you can use setStatusBarOrientation:animated: on the
UIApplication
to force the orientation.