- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
[self isPortraitSplash];
}
else if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
[self isLandScapeSplash];
}
return YES;
}
In my methods isPortraitSplash and isLandScapeSplash, i am setting the frames for the view.
When orientation changes, it’s always calling isLandScapeSplash – not able to call isPortraitSplash method.
Can any one advise me why this is happening?
Your existing
ifstatement is comparing aBOOLto aUIDeviceOrientation. Your test needs to be:UIInterfaceOrientationIsPortraitreturns a BOOL, so that’s all you need in yourifstatement condition.Update: I will also add that I agree with the other answers that it’s better to do this work in
willRotateToInterfaceOrientation:duration:, instead ofshouldAutorotateToInterfaceOrientation:.But, that isn’t the reason your original code was failing. The original code was failing because of the
iftest comparing theUIDeviceOrientationto theBOOL.