2013-05-27 45 views

回答

1

設置部署目標的iOS 4.3可以確保您的應用支持的iOS 4.3及以上,除非你不使用,僅支持更高版本的ARC一樣,故事板的任何功能,自動佈局。最好在設備或模擬器上進行測試。您可以通過Xcode中下載的iOS4.3模擬器

Xcode-> preferances - >下載 - >的iOS 4.3模擬器

+0

然而,4.3模擬器不支持山獅。 – borrrden

+0

我相信ARC支持iOS 4.x是不是? –

+1

@gosho_ot_pochivka ARC在4.x中支持,但不完全。 4.0中不支持弱引用 –

0

您可以在任何設備,其IOS版本是大於或等於上運行部署目標由您設置。

因此請記住,您尚未使用該版本不支持的任何框架或功能。

希望它可以幫助你。

0

您可以隨時在4.3模擬器上測試您的應用程序。在「Scheme」菜單下選擇iPhone 4.3 Simulator(您可以在Xcode頂部的「Run」「Stop」按鈕的右側找到它)。如果你不能找到4.3模擬器的選項,那麼你需要下載它去Xcode->Preference->Downloads->Components->iOS 4.3 Simulator

有時xcode不會抱怨在6.1中使用新的功能運行於4.3。

1

如果你覺得你已經使用可能不會在其他iOS版本的類,然後你可以使用

使用NSClassFromString功能檢查相同。將類的名稱作爲字符串傳遞給此方法。

如果此函數的返回值爲零,則該類在運行應用程序的設備上不可用;

否則,該類可在設備上使用,您可以繼續使用它並按需要使用它。

下面是一個例子:

i am checking for NSJSONSerialization class, similarly you can check for your class also, 

if (NSClassFromString(@"NSJSONSerialization") != nil) { 
/* You can use this class */ 

    [NSJSONSerialization JSONObjectWithData:... /* Put data here */ 
         options:...   /* Put options here */ 
         error:...];  /* Handle errors here */ 
} else { 
    /* That class is not available */ 
} 
0

測試這種方式是非常有效的解決方案,但它不是100%保證

/** 
* Example usage: 
* If you want to see if you're using methods that are only defined in iOS 4.0 and lower 
* then you would use the following. Replace the __IPHONE_4_0 with whatever other macro 
* you require. See Availability.h for iOS versions these relate to. 
* 
* YourProjectPrefixHeader.pch: 
* #define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_4_0 
* #import "ThisFile.h" 
* 
* // The rest of your prefix header as normal 
* #import <UIKit/UIKit.h> 
*/ 

#import <Availability.h> 

#define __AVAILABILITY_TOO_NEW __attribute__((deprecated("TOO NEW!"))) 

#ifndef __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED 
#define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_OS_VERSION_MIN_REQUIRED 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_OS_VERSION_MIN_REQUIRED 
#error You cannot ask for a soft max version which is less than the deployment target 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_0 
#undef __AVAILABILITY_INTERNAL__IPHONE_2_0 
#define __AVAILABILITY_INTERNAL__IPHONE_2_0 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_1 
#undef __AVAILABILITY_INTERNAL__IPHONE_2_1 
#define __AVAILABILITY_INTERNAL__IPHONE_2_1 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_2 
#undef __AVAILABILITY_INTERNAL__IPHONE_2_2 
#define __AVAILABILITY_INTERNAL__IPHONE_2_2 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_0 
#undef __AVAILABILITY_INTERNAL__IPHONE_3_0 
#define __AVAILABILITY_INTERNAL__IPHONE_3_0 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_1 
#undef __AVAILABILITY_INTERNAL__IPHONE_3_1 
#define __AVAILABILITY_INTERNAL__IPHONE_3_1 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_2 
#undef __AVAILABILITY_INTERNAL__IPHONE_3_2 
#define __AVAILABILITY_INTERNAL__IPHONE_3_2 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_0 
#undef __AVAILABILITY_INTERNAL__IPHONE_4_0 
#define __AVAILABILITY_INTERNAL__IPHONE_4_0 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_1 
#undef __AVAILABILITY_INTERNAL__IPHONE_4_1 
#define __AVAILABILITY_INTERNAL__IPHONE_4_1 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_2 
#undef __AVAILABILITY_INTERNAL__IPHONE_4_2 
#define __AVAILABILITY_INTERNAL__IPHONE_4_2 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_3 
#undef __AVAILABILITY_INTERNAL__IPHONE_4_3 
#define __AVAILABILITY_INTERNAL__IPHONE_4_3 __AVAILABILITY_TOO_NEW 
#endif 

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_5_0 
#undef __AVAILABILITY_INTERNAL__IPHONE_5_0 
#define __AVAILABILITY_INTERNAL__IPHONE_5_0 __AVAILABILITY_TOO_NEW 
#endif 
相關問題