【发布时间】:2012-02-15 17:30:36
【问题描述】:
我正在尝试将我的应用的初始方向设置为 UIInterfaceOrientationLandscapeLeft
我没办法
'Initial interface orientation'[UIInterfaceOrientation]
覆盖数组中的第一项
'Supported interface orientations'[UISupportedInterfaceOrientations]
我注意到一个 iphone 应用程序总是以“人像(底部主页按钮)”开头。数组是:
'Supported interface orientations'[UISupportedInterfaceOrientations]
Portrait (bottom home button)
Landscape (left home button)
Landscape (right home button)
正如预期的那样。
如果我将“摘要”页面上的 PORTRAIT HOME BOTTOM 按钮关闭 THEN BACK ON 然后数组的顺序发生变化,Portrait(底部主页按钮)移动到底部。
Landscape (left home button)
Landscape (right home button)
Portrait (bottom home button)
当我运行该应用程序时,它现在以横向(左主页按钮)启动,因为它现在位于列表顶部。哪个好
但是
当我添加时
'Initial interface orientation'[UIInterfaceOrientation]
并将其设置为
Landscape (right home button)
它被忽略,而是使用数组中的第一项
Landscape (left home button)
我检查了 shouldAutorotateToInterfaceOrientation ,它只阻止纵向倒置
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
我还添加了调试代码
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationPortrait){
NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait");
}else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown");
}else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft");
}else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight");
}else {
NSLog(@"shouldAutorotateToInterfaceOrientation:UNKNOWN");
}
return YES;
}
我明白了
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft
所以你可以看到它确实在尝试使用
'Initial interface orientation'[UIInterfaceOrientation]
并将其设置为
Landscape (right home button)
但随后它切换回数组中的第一项被使用
Landscape (left home button)
我做错了吗? 这是一个简单的 SINGLE VIEW Xcode 模板项目...只需添加调试代码。
【问题讨论】:
-
刚刚检查了另一个项目,他们删除了数组中的所有方向,除了他们想要的方向。然后将 Initial 设置为相同的值。不能在 ipad 上工作,应该支持它们并设置 inital。
标签: iphone ios uiinterfaceorientation device-orientation