-1
我已將選取器視圖添加到我的應用程序並將其設置爲數字數組。當我運行應用程序時,所有我看到的都是問號。帶數字顯示問號的swift選取器視圖
有誰知道問題是什麼?我也嘗試使用類型Int並收到相同的結果。
這是我的代碼。
import UIKit
import Firebase
import FirebaseDatabase
import FirebaseStorage
class myViewController: UIViewController, UIPickerViewDelegate,UIPickerViewDataSource {
@IBOutlet weak var settings: UIBarButtonItem!
@IBOutlet weak var myTextField: UITextField!
@IBOutlet weak var enterExit: UISegmentedControl!
@IBOutlet weak var dayLabel: UILabel!
@IBOutlet weak var pickerView: UIPickerView!
@IBOutlet weak var daysTextField: UITextField!
let numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
var hhh = Int()
let seconds = 60.0
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
private func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> Int? {
return numbers[row]
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return numbers.count
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
var days = numbers[row]
}
override func viewDidLoad() {
super.viewDidLoad()
self.pickerView.delegate = self
self.pickerView.dataSource = self
檢查:HTTPS://stackoverflow.com/questions/40199826/uipickerviewdelegate-xcode-8-swift-3,我認爲你需要了解'uipickerviewdelegate'和'uipickerviewdatasource' – 3stud1ant3
與更新你的問題您的相關代碼。顯示選取器視圖的委託和數據源方法。 – rmaddy
有我的代碼@ 3stud1ant3 –