簡體   English   中英

如何使用情節提要約束均勻地並排放置兩個UIPickerView?

[英]How can I evenly space two UIPickerView side by side using storyboard constraints?

有沒有一種方法可以使用storyboard約束均勻地UIPickerView兩個UIPickerView 我正在制作一個在橫向模式下在同一視圖中並排具有兩個UIPickerView的應用程序(我從未在此應用程序中使用縱向模式)。 所以我需要涵蓋所有電話尺寸。

在iPhone 4中,第一個UIPickerView從x = 0變為x = 240,第二個UIPickerView從x = 240變為x = 480。 如果用戶要使用更大的屏幕分辨率(iPhone 5),我希望具有相同的均勻間距。 我該如何實現? 如果無法使用storyboard進行編碼,該如何編碼? 謝謝。

嘗試使用以下圖像波紋中所示的約束:

在此處輸入圖片說明

我會編碼(個人喜好)。

通過出口,然后在self.viewDidLoad中,連接故事板選擇器:

// get half the width of the view that holds the pickers
float theWidth = self.view.frame.size.width / 2;

// Adjust the firstPicker
self.firstPicker.frame = CGRectMake (0,0,theWidth,self.firstPicker.frame.size.height);

// Adjust the secondPicker
self.secondPicker.frame = CGRectMake (theWidth, 0, theWidth,self.secondPicker.frame.size.height);

就是這樣-總是相同的大小和對齊,一半的視圖持有它。 為了方便起見,您可以繼續在Storyboard中移動內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM