Manoj Chandola
Manoj Chandola

Reputation: 156

How to rotate a single View Controller in IOS6

How to rotate a Single ViewController in iPad in ios6 . I have used the delegate in

appdelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

and it makes all viewcontroller Portrait and I want a single viewcontroller in between only in landscape mode.

in graphViewController.m

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

but i am unable to get the correct result, Please response asap. Thanks.

Upvotes: 5

Views: 609

Answers (2)

HpTerm
HpTerm

Reputation: 8281

See this link iOS6 Release Notes

Under UIKit -> Autorotation is changing in iOS 6

"More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate."

shouldAutorotate is never called (in iOS6) in any UIViewController which is inside another controller (for example a UINavigationController).

You should use the shouldAutorotate method of the UINavigationController (if you use one) to determine which child is display and force a given orientation

Upvotes: 3

Fazal Yazdan
Fazal Yazdan

Reputation: 46

used this method in the viewController you want to rotate not in app delegate.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

because in below method you are rotating window so thats why it change for whole application.

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}

Upvotes: 0

Related Questions