简体   繁体   English

设备方向

[英]device orientation

I dont know why the device orientation doesn't work. 我不知道为什么设备方向不起作用。

In the project properties: 在项目属性中:

在此处输入图片说明

In my code I have: 在我的代码中,我有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   return ((interfaceOrientation == UIInterfaceOrientationPortrait) || 
   (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
   (interfaceOrientation ==UIInterfaceOrientationLandscapeRight));
}

I probe it in my iphone and doesn't change. 我在iPhone上对其进行了探测,并且没有改变。

Is something missing? 缺少什么吗?

Thank you in advance 先感谢您

Edited (info.plist) 编辑(info.plist)

在此处输入图片说明

Open your info.plist file in XCode and add a line - Supported interface orientation of type array. XCode打开info.plist文件,并添加一行-数组类型Supported interface orientation

Hit the plus button next to it and list all orientations you want to use. 点击旁边的加号按钮,然后列出您要使用的所有方向。 You can set different settings for iPhone and iPad . 您可以为iPhoneiPad设置不同的设置。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if((interfaceOrientation == UIInterfaceOrientationPortrait) ||
   (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)||
   (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
{
    return YES;
}

return NO;

}

Where in your code is shouldAutorotateToInterfaceOrientation: implemented? 应该在代码中的哪个位置实现shouldAutorotateToInterfaceOrientation: It should be a method of each and every subclass of UIViewController . 它应该是UIViewController每个子类的方法。

Try making sure that it's working by putting a log statement or breakpoint in shouldAutorotateToInterfaceOrientation: . 通过在shouldAutorotateToInterfaceOrientation:放置一条日志语句或断点,尝试确保其正常工作。 If it's not being called, a view controller somewhere else is deciding your valid orientations for you. 如果没有被调用,则其他地方的视图控制器将为您确定有效的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM