开发者

UIViewController didRotateFromInterfaceOrientation argument fromInterfaceOrientation returning garbage value

开发者 https://www.devze.com 2023-03-19 18:12 出处:网络
When rotating the iPhone upside down during my tests, I found that while - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation开发者_如何学编程)fromInterfaceOrientation

When rotating the iPhone upside down during my tests, I found that while

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation开发者_如何学编程)fromInterfaceOrientation

gets called, the UIInterfaceOrientation parameter passed in as the argument is a garbage value (i.e. some random integer that is defined in the Apple documentation, instead of a UIInterfaceOrientation constant). How do I make it return a valid value?


It's not returning a garbage value.

Compare the value with the following constants:

UIInterfaceOrientationLandscapeLeft;
UIInterfaceOrientationLandscapeRight;
UIInterfaceOrientationPortrait;
UIInterfaceOrientationPortraitUpsideDown;

ie.

if (fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
     NSLog(@"PORTRAIT");
}

Or use the following BOOL macros:

UIInterfaceOrientationIsLandscape(fromInterfaceOrientation);
UIInterfaceOrientationIsPortrait(fromInterfaceOrientation);

ie.

if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) {
    NSLog(@"PORTRAIT");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消