我正在尝试为我的应用设置初始方向 UIInterfaceOrientationLandscapeLeft
我不能
'Initial interface orientation'[UIInterfaceOrientation]
覆盖
数组中的第一项'Supported interface orientations'[UISupportedInterfaceOrientations]
我注意到一个iphone应用总是以'Portrait(底部主页按钮)'开头。数组是:
'Supported interface orientations'[UISupportedInterfaceOrientations]
Portrait (bottom home button)
Landscape (left home button)
Landscape (right home button)
这是预期的。
如果我在摘要页面上关闭PORTRAIT HOME BOTTOM按钮OFF THEN BACK ON 然后数组的顺序改变,肖像(底部主页按钮)移动到底部。
Landscape (left home button)
Landscape (right home button)
Portrait (bottom home button)
当我运行应用程序时,它现在从横向(左主页按钮)开始,因为它现在是列表的顶部。这很好
BUT
当我添加
'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模板项目......只需添加调试代码。