我在项目中没有使用Size classes,并继续使用旧的视图控制器方向方法。当我使用如下代码时,会收到警告信息:
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
我已经搜索了很多,但是找不到正确的方法来修复它。有什么建议吗?
我在项目中没有使用Size classes,并继续使用旧的视图控制器方向方法。当我使用如下代码时,会收到警告信息:
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
应该更改
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
为了
if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
...
}
if view.bounds.size.width > view.bounds.size.height {
// ...
}
我很惊讶,但你可以在WWDC 2015视频的21'15处进行检查。 在iOS 9中开始使用iPad上的多任务处理
[[UIApplication sharedApplication] statusBarOrientation]
。 - vmeyer你们中的一些人可能需要使用UIDevice Orientation
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) {
...
}
使用状态栏方向代替
if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
...
}
traitCollection
作为尺寸类向您传达。显然,如果您拒绝查看它,您将看不到它。 - matt