开发者

UIViewController didRotateFromInterfaceOrientation argument fromInterfaceOrientation returning garbage value

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜