Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不同iOS版本的不同代码仍显示警告_Ios_Objective C_Ios9_Xcode7 - Fatal编程技术网

不同iOS版本的不同代码仍显示警告

不同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) {

我正在尝试清除iOS 9.0更新后应用程序的所有警告,我正在尝试执行以下操作:

#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