Eya*_*yal 4 iphone xcode objective-c autorotate device-orientation
我正在开发的iPhone应用程序中有一个奇怪的问题.我希望我的应用程序仅支持纵向模式,但由于某种原因我无法做到(设备和模拟器).
为了仅支持肖像模式我做了如下:
shouldAutorotateToInterfaceOrientation 但正如我所说它不起作用,奇怪的结果是该应用程序支持所有方向(纵向,颠倒,左侧景观,右侧景观).
有任何想法吗?
这是我如何实现的 shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
NSLog(@"Checking orientation %d", interfaceOrientation);
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)
我刚刚注意到,当我旋转手机时,我收到以下消息:
"不推荐使用两阶段旋转动画.此应用程序应使用更平滑的单级动画."
这是什么意思?
转到 info.plist 文件。右键单击将其作为源代码打开。并寻找这条线。对我来说,iPad 是这样的:
<key>UISupportedInterfaceOrientations~ipad</key>
Run Code Online (Sandbox Code Playgroud)
删除所有其他方向并保留您唯一需要的方向..像这样:
<array>
<string> UIInterfaceOrientationPortrait </string>
</array>
Run Code Online (Sandbox Code Playgroud)
屏幕上可以有多个 ViewController。它UITabBarController本身就是 a UIViewController,并且它仅shouldAutorotateToInterfaceOrientation:在选择时才将请求传递给其中的 viewController。默认实现会执行此操作,但如果您将其子类化,则 XCode 生成的代码(从 iOS 5.1 开始)不会执行此操作。
| 归档时间: |
|
| 查看次数: |
8277 次 |
| 最近记录: |