Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

xcode4.5 - Top-home button portrait orientation in iOS6 simulator not working

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...