What is the objc code for below swift statement?
if (UIDevice.currentDevice().orientation.isLandscape)
what i figured out so far is
if ([[UIDevice currentDevice] orientation])
From apple Docs:-
BOOL UIDeviceOrientationIsLandscape(UIDeviceOrientation orientation);
Returns a Boolean value indicating whether the device is in a landscape orientation.
So try this:-
if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){
//True if landscape is on
}
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
BOOL isLandscape = UIDeviceOrientationIsLandscape(orientation);
if (isLandscape) {
NSLog(@"Landscape orientation")
//Do the work
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.