2015-12-02 26 views
2

我提交我的應用程序進行審查,並得到了錯誤對不同的屏幕尺寸使用不同的故事板?通用的Xcode應用

2.10 - iPhone應用程序也必須在iPad上運行而無需修改,在iPhone的分辨率,並以2倍iPhone 3GS的分辨率。我們注意到,在運行iOS 9.1的iPad上進行審覈時,您的應用沒有以iPhone解析度運行,這違反了App Store審查準則。我們附上了截圖以供參考。具體來說,當我們在iPad上點擊登錄Facebook時,不會產生任何操作,我們無法讓應用程序前進。

我抄第二個故事板,用於與信息的plist和常規設置等,我還需要爲不同的iPhone設備不同的故事板,你可以從我的形象設計是不可能的自動約束看到的iPad。

if you look at the age it is not able to go in the box in the last 3 only the first

什麼我的問題是:做我只是IB老視圖控制器的方式,我對故事板1做相同的,每個VC重複的代碼或做我必須創造一個全新的風投新的故事板包括應用程序代表?其次,我是否必須在我的應用程序委託中編寫代碼,以根據屏幕大小或劑量說明要使用哪個故事板?xcode 7在信息plist中執行此操作嗎?我所能找到的只是objc代碼,我只知道很快。

so question obj c xcode 5

link ipad and main storyboard

回答

4

我不能使用所有器件尺寸故事板一個原因是我的設計限制,因此要解決我的問題,我添加此代碼,以我的應用程序委託:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 

    var bounds: CGRect = UIScreen.mainScreen().bounds 
    var screenHeight: NSNumber = bounds.size.height 
    var deviceFamily: String 

    var mainView: UIStoryboard! 
    mainView = UIStoryboard(name: "iphone35Storyboard", bundle: nil) 
    let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone35") as UIViewController 
    self.window!.rootViewController = viewcontroller 

    if screenHeight == 480 { 
     deviceFamily = "iPhoneOriginal" 
     // Load Storyboard with name: iPhone4 
     var mainView: UIStoryboard! 
     mainView = UIStoryboard(name: "Main", bundle: nil) 
     let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("iphone4") as UIViewController 
     self.window!.rootViewController = viewcontroller 

    } else { 

     var mainView: UIStoryboard! 
     mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil) 
     let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController 
     self.window!.rootViewController = viewcontroller 

     if screenHeight == 920 { 
      deviceFamily = "Pad" 
      // Load Storyboard with name: ipad 
      var mainView: UIStoryboard! 
      mainView = UIStoryboard(name: "IpadStoryboard", bundle: nil) 
      let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("ipad") as UIViewController 
      self.window!.rootViewController = viewcontroller 
     } 
    } 
} 

然後創建一個新的故事板,將主要故事板複製並粘貼到第二個故事板並調整大小。它的工作,我做了同樣的,然後爲不同的iPhone尺寸。希望這可以幫助別人。

2

你並不需要不同的故事板,你只需要一個!你所要做的就是使用大小班級。您可以在單個故事板上工作,並設置不同的佈局約束,或者爲每個尺寸類別設置不同的UI元素。

Apple documentation

Tutorial

+0

嗨,感謝教程我現在就去看看。你能否回答我一個問題,即使我的設計像上圖一樣設置,你是否看到了背景圖像在實際背景圖像中的年齡和生物框的方式上傳,所以當我添加該年齡的文本字段不在年齡框中,它會在不同的屏幕上顯示?我只是擔心自適應佈局只適應一切,但實際上並沒有將它們放在我需要它們的確切位置。如果你找到我了嗎? – Grace

+0

@Grace您需要爲故事板中的每個視圖設置佈局約束。在你的情況下,你可能希望將年齡放在方框中。如果您爲任何配置設置了約束,那麼它將被任何大小的類配置使用! – ravalboy

+0

在某些設計案例中,大小類不夠動態。它將iPhone 7的寬度和高度視爲與4s(C:R)相同,當兩種尺寸大不相同時。 –