문제

I have a UIScrollView with sub-views whose frames I have to update on orientation change. I have been running the program on an iPhone simulator but it looks like the UIDeviceOrientationDidChangeNotification does not return the correct orientation of the device. It returns UIInterfaceOrientationPortrait when I rotate to UIInterfaceOrientationLandscapeLeft/Right and vice versa. Am I not using it right or do I have to use some other method of handling orientation change?

도움이 되었습니까?

해결책

UIInterfaceOrientation != UIDeviceOrientation. UIInterfaceOrientation is declared as ...

typedef enum : NSInteger {
   UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
   UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
   UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
   UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;

... portrait contains same values / numbers, but landscape variants are swapped, etc. You didn't show your code, so, I can just assume, that you're mixing these two things together.

Is there any reason why you're not using willRotateTo..., willAnimateRotation..., didRotateFrom... methods of UIViewController?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top