以下swift声明的objc代码是什么?
if (UIDevice.currentDevice().orientation.isLandscape)
我到目前为止所知道的是
if ([[UIDevice currentDevice] orientation])
答案 0 :(得分:1)
来自apple Docs: -
BOOL UIDeviceOrientationIsLandscape(UIDeviceOrientation orientation);
返回一个布尔值,指示设备是否在 景观定位。
所以试试这个: -
if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)){
//True if landscape is on
}
答案 1 :(得分:1)
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
BOOL isLandscape = UIDeviceOrientationIsLandscape(orientation);
if (isLandscape) {
NSLog(@"Landscape orientation")
//Do the work
}