2014-10-29 49 views
6

試圖在Xcode的新故事板設計iphone的UI: enter image description here的Xcode 6.1 iPhone/iPad的故事情節

enter image description here

這似乎是爲設計只是iphone的UI有點雜亂無章。我期望某種形式的'iphone''ipad''可擴展的'邊界或線條,但我可以找到的只有這一個單獨的故事板。 現在是真的只是單個故事板還是我缺少一些額外的控制?

+1

查看自動佈局,或彈簧和Struts,如果你像我一樣老式。 – Undo 2014-10-29 15:30:05

+0

我不介意單一視圖,我認爲這將是集中的,有額外的空間可用於ipad。或者至少是某種形式的指導什麼時候在哪裏觀看。哦,歡呼的提示 – 2014-10-29 15:31:23

回答

1

在公用區域選擇您的故事板

顯示Atributes inspector > Simulated Metrics > Size > Select Size

16

與XCode的6起,iPhone和iPad的故事板都使用一種稱爲大小類的新功能被合併。這是一件好事(大部分時間),因爲它可以讓你設計一個適應不同屏幕尺寸的界面。

當然,在某些情況下,您可能想要爲iPhone和iPad使用不同的故事板。畢竟,有些應用程序在手掌和平板電腦大小的設備上只需要一種完全不同的方法。

如果您想使用新的Size Classes,請參閱越來越多的教程,比如Ray Wenderlich編寫的一個:http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial

如果你想使用iPhone和iPad不同的故事板,方法如下:

  1. 開始一個新的單一視圖中的應用。

    a. Select File|New|Project. 
    
    b. Select iOS, Application and click "Single View Application." 
    
    c. Click Next. 
    
    d. Give the project a name, then click "Next." 
    
    e. Pick a location and click "Create" to create the project. 
    
  2. 將起始故事板轉換爲iPhone故事板。

    a. Select Main.storyboard, and select the file inspector (the document icon at the top of the right pane) if it is not already selected. 
    
    b. Uncheck "Use Size Classes." 
    

Uncheck Use Size Classes to convert to a device-specific storyboard.

c. A dlialog will appear. Select "iPhone" from the drop down menu, then click "Disable Size Classes." 

Choose iPhone and click Disable Size Classes

d. Rename the storyboard as "Main_iPhone.storyboard." 

enter image description here

  • 創建iPad故事板。

    a. Select File|New|File from the menu bar. From the dialog that appears, select iOS|UserInterface. Click on "Storyboard" and click "Next." 
    
  • enter image description here

    b. Rename the file as "Main_iPad.storyboard," then save it, typically in the Base.lproj folder of your project folder. 
    

    enter image description here

    c. Add a view controller, and make it the initial view controller by clicking the "Is Initial View Controller" check box in the Attributes Inspector pane. 
    

    enter image description here

  • 按照與上面#2相同的步驟將新的故事板轉換爲iPad故事板,但是這次在選擇平臺時選擇iPad而不是iPhone。

  • 將故事板鏈接到應用程序。

    a. Open the Info.plist. 
    
    b. Change the name for "Main storyboard file base name" from "Main" to "Main_iPhone.storyboard". 
    
    .c Add a new property called "Main storyboard file base name (iPad)" and give it the name "Main_iPad." 
    
  • enter image description here

    這就是它!現在,您可以像往常一樣爲iPhone和iPad創建單獨的用戶界面。

    +1

    我希望上帝會照顧你...謝謝我解決我的問題與你的問題:) – 2015-04-16 10:32:56

    +0

    這是一個美妙的解釋 – anoop4real 2016-01-13 16:49:09