2015-09-25 72 views
0

我試圖清除,因爲在更新到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 

但我我仍然得到所有的警告,我做錯了什麼?

我發現這條指令在iOS 8.0和iOS 7.0中無法正常工作。

- (UIInterfaceOrientationMask)supportedInterfaceOrientations 

回答

1

我認爲 - (NSUInteger)supportedInterfaceOrientations {}不適用於iOS 9.0。

所以,你必須使用 - (UIInterfaceOrientationMask)supportedInterfaceOrientations。它適用於所有的iOS版本。

不檢查iOS版本。僅針對所有iOS版本使用
- (UIInterfaceOrientationMask)supportedInterfaceOrientations方法。

-2

您的#if代碼和#else代碼是相同的。那麼你期望什麼?

+0

它們不相同。返回類型是不同的。 – rmaddy