Ipad模拟器不自动旋转
我有一个 iPhone 应用程序,并使用 shouldAutorotateToInterfaceOrientation
来确定何时自动旋转。在 iPhone 上,我指定 UIInterfaceOrientationPortrait
是唯一允许的方向;在 iPad 上,我只是返回 YES(即全部允许),如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //also tried using [[UIDevice currentDevice] userInterfaceIdiom] to no avail
return YES; //doesn't get here
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
这位于选项卡栏的每个视图控制器中。当我 NSLog() [[UIDevice currentDevice] userInterfaceIdiom]
时,它返回 0(或 UIUserInterfaceIdiomPhone
)。
iPad 模拟器是否始终返回 UIUserInterfaceIdiomPhone
?
I have an an iphone app and am using shouldAutorotateToInterfaceOrientation
to determine when to autorotate. On the iphone, I specify that UIInterfaceOrientationPortrait
is the only allowed orientation; On the iPad, I just return YES (ie all allowed), like so:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //also tried using [[UIDevice currentDevice] userInterfaceIdiom] to no avail
return YES; //doesn't get here
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
This is in every view controller of the tab bar. When I NSLog() the [[UIDevice currentDevice] userInterfaceIdiom]
, it returns 0 (or UIUserInterfaceIdiomPhone
).
Does the iPad simulator always return UIUserInterfaceIdiomPhone
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你的答案就在这里: UI_USER_INTERFACE_IDIOM 是否与 Targeted 一起使用设备系列
I think your answer is here: Does UI_USER_INTERFACE_IDIOM work with Targeted Device Family