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");
}
精彩评论