如何在IOS6中旋转单个视图控制器

Man*_*ola 5 iphone ios6

如何ViewController在iPad中旋转单曲ios6.我已经使用过代表了

appdelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

它使所有viewcontroller肖像和我想要viewcontroller只在横向模式之间的单一.

在graphViewController.m中

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)

但我无法得到正确的结果,请尽快回复.谢谢.

小智 0

在要旋转的 viewController 中使用此方法而不是在 app delegate.m 中

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)

因为在下面的方法中您正在旋转窗口,所以这就是为什么它会针对整个应用程序发生变化。

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)