小编Kas*_*yas的帖子

iOS 6设备定位问题

我有2个视图控制器.我希望第一个viewcontroller只是Portrait模式,而第二个viewController应该支持所有方向.请帮我.

在AppDelegate类中,我的代码是:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
    UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = self.viewController;
  //  [self.window addSubview:navController.view];
    [self.window makeKeyAndVisible];   
    return YES;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    NSLog(@"supportedInterfaceOrientationsForWindow");
    return  UIInterfaceOrientationMaskAllButUpsideDown;
}
Run Code Online (Sandbox Code Playgroud)

第一个ViewController代码是:

-(BOOL)shouldAutorotate
{
    return NO;
}


-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

第二个ViewController代码是:

-(NSUInteger)supportedInterfaceOrientations …
Run Code Online (Sandbox Code Playgroud)

orientation ios6 iphone-5

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios6 ×1

iphone-5 ×1

orientation ×1