Calios Calios - 2 months ago 14
Objective-C Question

Fail to jump from a portrait view to a landscape view

Everyone. I've got two views. The first view supports only landscape orientation and the second view supports all orientations. However, when the second view is portrait and a button is pressed, it jumps to the first one portrait, which is meant to be landscape.

I've added the following two method in the first ViewController.

- (BOOL)shouldAutorotate
{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}


I wonder if anyone could help me, since this issue had puzzled me for long.
Thanks in forward!!

mAc mAc
Answer

I am not sure that whether i got u correctly or not. upto what i got is that you have 2 viewControllers, first viewController supports only Landscape while 2nd viewController supports all Orientations. But you r having problem in maintaining this. Check whether you have implemented this in your code, if u still find any problem, do revert back and if it solves kindly Accept the answer and vote it up too ;) :-

1) Your first viewController should have this :- // for iOS 6

-(BOOL)shouldAutorotate{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

for < iOS 6

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

2) Your second viewController Should have this:- for iOS 6

-(BOOL)shouldAutorotate{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

for < iOS6

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}