xcode 在 iOS 应用中锁定旋转
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15923853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Lock rotation in an iOS app
提问by Kevin
As my Linphone adventurecontinues, I am now able to compile it and run it on my dev ipad. One problem I have with the app is that it's orientation is always the same as the device's orientation. I have read through some answers around here about this, but none seem to work for me. I'm very new to iOS development and Mac usage in general. From what I understand, I can set my orientation settings in the root view, but I have no clue which one that is.
随着我的Linphone 冒险的继续,我现在可以编译它并在我的开发 iPad 上运行它。我对应用程序的一个问题是它的方向始终与设备的方向相同。我已经阅读了这里的一些关于此的答案,但似乎没有一个对我有用。总的来说,我对 iOS 开发和 Mac 使用非常陌生。据我所知,我可以在根视图中设置我的方向设置,但我不知道那是哪一个。
The current situation:
The introscreen is always in landscapeleft mode (home button to the left of the device).
Every other view is automatically rotated when I rotate the device.
当前情况:
介绍屏幕始终处于横向左模式(设备左侧的主页按钮)。
当我旋转设备时,所有其他视图都会自动旋转。
What I have tried:
I tried copying the following code to all my views, which did not seem to do anything at all.
我尝试过的:
我尝试将以下代码复制到我的所有视图中,这似乎根本没有做任何事情。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) return YES;
return NO;
}
I tried setting the 'Supported interface orientations' and 'Supported interface orientations (iPad)' to 'Landscape (left home button)' (deleted the other entries).
I have also used the code sample in a few different formats, as suggested in similar questions on SO and other forums. So I doubt the code is wrong.
我尝试将“支持的界面方向”和“支持的界面方向(iPad)”设置为“横向(左主页按钮)”(删除了其他条目)。
我还使用了几种不同格式的代码示例,如 SO 和其他论坛上的类似问题所建议的那样。所以我怀疑代码是错误的。
Additional details:
I'm using the latest version of linphone.
I'm using xcode 4.6.1.
I'm using an iPad 3 and an iPad 4 for testing both with firmware 6.1.3, I also tried the simulators that come with xcode.
I'm running xcode on an iMac with Mountain Lion 10.8.3.
其他详细信息:
我使用的是最新版本的 linphone。
我正在使用 xcode 4.6.1。
我正在使用 iPad 3 和 iPad 4 来测试固件 6.1.3,我还尝试了 xcode 附带的模拟器。
我在装有 Mountain Lion 10.8.3 的 iMac 上运行 xcode。
The weird thing is that the code worked for the introscreen (a simple splash screen, showing the linphone logo and name), but not for any other view.
奇怪的是,该代码适用于介绍屏幕(一个简单的闪屏,显示 linphone 徽标和名称),但不适用于任何其他视图。
How do I lock my entire app in the landscape left orientation (so the app is viewed correctly when the home button is on the left side of the device)?
如何将我的整个应用程序锁定在横向左侧方向(以便当主页按钮位于设备左侧时可以正确查看应用程序)?
回答by Kevin
Apparently, rotation is handled by the Linphone SDK, I found it in linphonecore.c. After I edited this file and compiled the whole SDK again, my view was succesfully locked in landscape left mode.
显然,旋转是由 Linphone SDK 处理的,我在 linphonecore.c 中找到了它。在我编辑此文件并再次编译整个 SDK 后,我的视图成功锁定在横向左侧模式。