我正在尝试将我的应用程序的初始方向设置为 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 按钮关闭然后重新打开,则阵列的顺序会发生变化,并且人像(底部的主页按钮)会移动到底部。
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 模板项目...只需添加调试代码。