不同iOS版本的不同代码仍显示警告
我正在尝试清除iOS 9.0更新后应用程序的所有警告,我正在尝试执行以下操作:不同iOS版本的不同代码仍显示警告,ios,objective-c,ios9,xcode7,Ios,Objective C,Ios9,Xcode7,我正在尝试清除iOS 9.0更新后应用程序的所有警告,我正在尝试执行以下操作: #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0 // less than iOS 9.0 - (NSUInteger)supportedInterfaceOrientations { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0
// less than iOS 9.0
- (NSUInteger)supportedInterfaceOrientations
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskPortrait;
} else {
return UIInterfaceOrientationMaskAll;
}
}
#else
// iOS 9.0 or later
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskPortrait;
} else {
return UIInterfaceOrientationMaskAll;
}
}
#endif
您的#if代码和#else代码相同。那么你期待什么呢 我想
-(NSUInteger)支持的接口方向{}在iOS 9.0中不起作用
因此,您必须使用-(UIInterfaceOrientationTask)支持的接口方向。它在所有iOS版本中都能工作
不要检查iOS版本。只需使用-(UIInterfaceOrientationMask)支持所有iOS版本的界面定向方法。它们不相同。返回类型不同。
- (UIInterfaceOrientationMask)supportedInterfaceOrientations