2014-01-09 25 views
1

This is for ios 7 looks perfectThis for is ios 6我花了一整天的時間嘗試讓我的產品兼容ios7和ios6,但累了。當我在ios 7中運行並設置完畢後,我的應用程序運行完美基礎sdk作爲ios7和更高版本。另外我把部署目標設置爲7.0。如何在使用xcode5時使應用程序與ios6兼容

現在,當我將基礎sdk設置爲ios6並將部署目標設置爲6.1時,我的應用程序仍在運行,但問題在於它的GUI失真。嘗試在模擬器6.1,也得到這個問題。

導航欄隱藏和所有圖像標籤textfield tableview也設置爲底部,因爲它們在ios7中的固定位置。我不想把4個xib放在3.5英寸顯示器和4英寸顯示器上。

+0

你爲什麼不使用它會解決您最問題的自動佈局工作,還需要檢查iOS系統運行以便您可以調整您的視圖,尋找升級指南 – Retro

+0

@Retro,但如果我使用自動layout.and設置3.5英寸導航欄它也會影響到4英寸顯示器,所以我怎麼能? –

+0

使用自動佈局通過http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 您不需要2或4個xib,您可以使用單個xib來完成。 –

回答

-1

在info.plist中添加標記(視圖控制器基於...從plist中lastone)將其設置爲NO

+0

if([selfrespondsToSelector:@selector(edgesForExtendedLayout)]) self.edgesForExtendedLayout = UIRectEdgeNone; – user2211689

1

對於我來說,如果我不得不做出這樣的基於我用下面的不同IOS版本的變化類來定義可以檢測我正在使用哪個版本的函數。它也只需要一個頭文件(.h)文件和沒有實現(.m)文件。

我把這個類叫做VersionMacros。

VersionMacros.h:

/* 
* System Versioning Preprocessor Macros 
* Incluse this header if you want to adjust something based on a system version 
*/ 

#define SYSTEM_VERSION_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) 
#define SYSTEM_VERSION_GREATER_THAN(v)    ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) 
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 
#define SYSTEM_VERSION_LESS_THAN(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) 

//Use these functions to detect versions. Also import this header file into the file u want to use these funcs. 

然後,當你想使用一個不同的廈門國際銀行兩個版本你可以調用它。

 if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO("7.0")) 
     { 
      //The version of the device is iOS7.0 or higher. 

      //call controller with ios7 xib here 
     } 
     else 
     { 
      //The version of the device is lower then iOS7.0. 

      //call controller with ios6 xib here 
     } 

除了調用和調用不同的xib,您還可以調整需要調整的元素的框架。 (這是我更喜歡的) 這看起來像這樣。

float versionMarginY = 0.0; 

if(SYSTEM_VERSION_EQUAL_TO("7.0")) 
{ 
    //if system version is exactly 7.0 
    versionMarginY = 64.0; 
} 
else if(SYSTEM_VERSION_EQUAL_TO("6.0")) 
{ 
    //if system version is exactly 6.0 
    versionMarginY = 44.0; 
} 
else 
{ 
    //for all other versions we do this 
} 

//Then adjust a certain view that you can reach in this method 
someView.frame = CGRectMake(0, 0 + versionMarginY, someWidthThatHasSomeKindOfValue, someHeightThatHasSomeKindOfValue); 

希望這有助於!

+0

有一個錯誤,我必須把V的insted我試過了,但它得到錯誤。 –

+0

WhatView將在SomeView中? –

+0

而不是v你應該把iOS版本號作爲一個字符串。像例子中的「6.0」或「7.0」一樣。 SomeView將是您可以管理的xib中的元素。就像你把一些UIView放在你的xib上並與你的視圖控制器相連 –

0

我用這個條件來解決由碼圖形的問題與iOS 6和7

if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){ 
     //make it look nice iOS7 
} 
相關問題