0

UINavigationControllerを使用しても、向きのステータスは変わりません。これは私のコードです:

AppDelegate.hファイル

#import <UIKit/UIKit.h>
@class MainViewController;
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) MainViewController *mainViewController;
@end

AppDelegate.mファイル

...

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDistionary* launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
self.mainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
UINavigateionController *navigationController = [[UINavigationController alloc]initWithRootViewController:self.mainViewController];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
....

MainViewController.m

...
-(NSUInteger)supportedInterfaceOrientations{
    return  UIInterfaceOrientationMaskLandscapeLeft;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationMaskLandscapeLeft;
}
-(BOOL)shouldAutorotate{
    return YES;
}
-(void) viewDidAppear:(BOOL)animated {

    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
    [self.navigationController setNavigationBarHidden:YES];
}
...
4

1 に答える 1

0

From iOS 6.0 SDK Release Notes:

The setStatusBarOrientation:animated: method is not deprecated outright. It now works only if the supportedInterfaceOrientations method of the top-most full-screen view controller returns 0. This makes the caller responsible for ensuring that the status bar orientation is consistent.

于 2012-10-20T00:39:08.440 に答える