Question

I have two views in my app; "Calculator" and the "Tape". I can click on the button inside calculator to get to the tape and vice versa. I set the rotation as per code below and it works fine most of the time.

However there are issues if I rotate either calculator view or tape view to landscape and then if I try to access other view, interface is all messed up like it doesn't recognize that device was already rotated. Any suggestions?

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [self doLayoutForOrientation:toInterfaceOrientation]; 
}


- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation { 
if (UIInterfaceOrientationIsPortrait(orientation)) 
{
//set the frames here
}
else 
{
//set the frames here
} 
}
Was it helpful?

Solution

write these codes in the view will appear of each view.

 UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//adjust the view for landscape
}
else if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//adjust the view for portrait.
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top