-1
目的更多的選擇:
- 要設置選擇挑年齡,玩家數量和局
- 值年齡應該是8,9,10
- 值的數字應該是0-99的
- 值局應該是1-6
問題:
只有3個選項出現在每個我測試時,如果有更多的數組,他們沒有出現,如果有更少的崩潰。多選擇選擇器視圖不能有一個比別人
問題:
- 如何顯示的每個項目的選擇是否正確?
- 如何使0-99選取器走0,1,2 ...而不必列出每個單獨的數字,如0 ... 99(我試過這個,它不起作用)?
代碼:
import UIKit
class PitcherPickerViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet weak var picker: UIPickerView!
var pickerData: [[String]] = [[String]]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Connect data:
self.picker.delegate = self
self.picker.dataSource = self
// Input data into the Array:
pickerData = [["8", "9", "10"],
["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "91", "92", "93", "94", "95", "96", "97", "98", "99"],
["1", "2", "3", "4", "5", "6"]]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// The number of columns of data
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 3
}
// The number of rows of data
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
// The data to return for the row and component (column) that's being passed in
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[component][row]
}
// Catpure the picker view selection
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
// This method is triggered whenever the user makes a change to the picker selection.
// The parameter named row and component represents what was selected.
}
}
+1謝謝你,當我把它發佈爲15天左右前,但我想我的評論從來沒有通過你的時候,從字面上來說是一種拯救生命,我無法相信一件小事可以認真地改變一切,再次感謝 – Branson