Set orientation to landscape mode in xcode 4.5 GM IOS 6(在 xcode 4.5 GM IOS 6 中将方向设置为横向模式)
问题描述
我使用游戏中心开发了 IOS 5 应用程序.现在我希望我的代码在 IOS 6 上运行.所以我让我的应用程序同时支持方向,即横向和纵向,以便在弹出游戏中心登录屏幕时它不会崩溃.但在那之后,我的主视图控制器不会以横向视图启动.相反,当我进入更远的视图时,它以横向打开,然后当我回来时,主视图以横向打开.但是主页视图第一次没有打开横向模式.
I developed IOS 5 application using game center. Now I want my code to run on IOS 6. So I have let my application to support both orientation i.e landscape and portrait so that it does not crashes when game center login screen pops up. But after that, my home view controller does not starts in landscape view. Instead when I go to a further view, it opens in landscape, and then when i come back, then the home view opens in landscape. But home view does not opens to landscape mode for the first time.
代码如下:
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
这些是我在 IOS 6 的主页视图中使用的代表.
These are the delegates I use in home view for IOS 6.
推荐答案
在您的应用委托中添加此方法以支持 IOS 6 所需的方向..
Add this method in your app delegate to support desired orientation for IOS 6..
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
并在 IOS 6 的其他类中使用这些 delegates 进行定向.
and use these delagates for orientation in rest of clases for IOS 6.
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
这篇关于在 xcode 4.5 GM IOS 6 中将方向设置为横向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 xcode 4.5 GM IOS 6 中将方向设置为横向模式
基础教程推荐
- 我的 UIImageView 的任务 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
