iOS XCode : Check Orientation
I use in my method :
- (CGFloat)setWidthPopupValue {
- (CGFloat)setWidthPopupValue {
//NSLog(@"%ld", (long)[UIDevice currentDevice].orientation);
if ((long)[UIDevice currentDevice].orientation == 0 || (long)[UIDevice currentDevice].orientation == 1)
{
return self.view.frame.size.width * 0.8;
} else {
return self.view.frame.size.width * 0.5;
}
}
0, 1, for portrait
and 3 for landscape
I don't use UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)
because while i return value from [UIDevice currentDevice].orientation, it has 3 possibility value, 3 for landscape, 1 for portrait, and 0 after i open browser over link in webview.