iOS6模拟器中的顶部主页按钮纵向方向无法正常工作 [英] Top-home button portrait orientation in iOS6 simulator not working

查看:110
本文介绍了iOS6模拟器中的顶部主页按钮纵向方向无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几分钟前我设置了XCode 4.5和iOS6模拟器。
我的应用程序支持iPhone的所有 4 方向,
纵向底部和顶部主页按钮,左右横向。



<嗯,我把它放到.plist中,因为它是iOS6所要求的,而且旧的shouldRotateTo ...方法仍然在那里返回YES。



但是在模拟器,应用程序旋转到纵向顶部主页按钮。



为什么?这是出于目的吗?它在设备上是否正常工作?



谢谢。

解决方案

确定,
我现在找到了答案。



这还不够

   - (BOOL)shouldAutorotate {

返回YES;
}

- (NSUInteger)supportedInterfaceOrientations {

返回UIInterfaceOrientationMaskAll;
}

在你的ViewController中,如果它被推入 UINavigationViewController
UINavigationViewController 也必须有这些方法。
最好通过在 UINavigationViewController 上设置一个小类别来实现这一点。



这是我的 UINavigationController-Rotation.h

  @interface UINavigationController(Rotation)
@end

和我的UINavigationController-Rotation.m:

  #importUINavigationController-Rotation.h

@implementation UINavigationController(Rotation)

#pragma来自UINavigationController

- (BOOL)shouldAutorotate {

BOOL result = self.topViewController.shouldAutorotate;

返回结果;
}

- (NSUInteger)supportedInterfaceOrientations {

NSUInteger result = self.topViewController.supportedInterfaceOrientations;

返回结果;
}

#pragma -

@end

感谢您的帮助!


I set up XCode 4.5 and iOS6 simulator a few minutes ago. My app supports all 4 orientations of the iPhone, portrait bottom and top home button, landscape left and right.

Well, I put that to the .plist as it is required by iOS6 and also the old shouldRotateTo... method is still there returning YES.

But in the simulator, the App is not rotating to portrait top home button.

Why? Is this by purpose? Would it work correct on device?

Thanks.

解决方案

OK, I found the answer now myself.

It is not enough to have

- (BOOL)shouldAutorotate {

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskAll;
}

in YOUR ViewController if it is pushed into a UINavigationViewController. The UINavigationViewController also has to have those methods. Preferably, you do this by having a small Category on UINavigationViewController.

This is my UINavigationController-Rotation.h:

@interface UINavigationController (Rotation)
@end

and my UINavigationController-Rotation.m:

#import "UINavigationController-Rotation.h"

@implementation UINavigationController (Rotation)

#pragma From UINavigationController

- (BOOL)shouldAutorotate {

    BOOL result = self.topViewController.shouldAutorotate;

    return result;
}

- (NSUInteger)supportedInterfaceOrientations {

    NSUInteger result = self.topViewController.supportedInterfaceOrientations;

    return result;
}

#pragma -

@end

Thanks for helping me!

这篇关于iOS6模拟器中的顶部主页按钮纵向方向无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆