bri*_*ear 3 iphone uiinterfaceorientation device-orientation ios
我正在尝试将我的应用的初始方向设置为UIInterfaceOrientationLandscapeLeft
我不能
'Initial interface orientation'[UIInterfaceOrientation]
Run Code Online (Sandbox Code Playgroud)
覆盖数组中的第一项
'Supported interface orientations'[UISupportedInterfaceOrientations]
Run Code Online (Sandbox Code Playgroud)
我注意到一个iphone应用总是以'Portrait(底部主页按钮)'开头.数组是:
'Supported interface orientations'[UISupportedInterfaceOrientations]
Portrait (bottom home button)
Landscape (left home button)
Landscape (right home button)
Run Code Online (Sandbox Code Playgroud)
这是预期的.
如果我在摘要页面上关闭PORTRAIT HOME BOTTOM按钮OFF THEN BACK ON然后数组的顺序改变而Portrait(底部主页按钮)移动到底部.
Landscape (left home button)
Landscape (right home button)
Portrait (bottom home button)
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,它现在从横向(左主页按钮)开始,因为它现在是列表的顶部.哪个好
但
当我添加
'Initial interface orientation'[UIInterfaceOrientation]
Run Code Online (Sandbox Code Playgroud)
并将其设置为
Landscape (right home button)
Run Code Online (Sandbox Code Playgroud)
它被忽略,而数组中的第一项则被使用
Landscape (left home button)
Run Code Online (Sandbox Code Playgroud)
我检查了shouldAutorotateToInterfaceOrientation,它只阻止了肖像颠倒
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
Run Code Online (Sandbox Code Playgroud)
我还添加了调试代码
- (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;
}
Run Code Online (Sandbox Code Playgroud)
我明白了
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft
shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft
Run Code Online (Sandbox Code Playgroud)
所以你可以看到它确实尝试使用
'Initial interface orientation'[UIInterfaceOrientation]
Run Code Online (Sandbox Code Playgroud)
并将其设置为
Landscape (right home button)
Run Code Online (Sandbox Code Playgroud)
但后来切换回数组中的第一个项目
Landscape (left home button)
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?这是一个简单的SINGLE VIEW Xcode模板项目......只需添加调试代码即可.
mat*_*att 16
尽管有文档,但是UIInterfaceOrientation
被忽略了.仅限使用UISupportedInterfaceOrientations
.要指定您希望启动哪个,请将其作为第一个列出UISupportedInterfaceOrientations
.
然后由您的个人视图控制器来排除他们拒绝采用的任何方向.
归档时间: |
|
查看次数: |
5478 次 |
最近记录: |