【发布时间】:2020-05-22 02:54:34
【问题描述】:
我有一个带有 UIPickView 的应用程序,它在模拟器中完美运行,但是当我在设备上运行该应用程序时,它显示为空。
重要提示:它只是看起来是空的,因为我仍然可以滚动它并且所选项目正在改变。
class ViewController: UIInputViewController, UIPickerViewDelegate, UIPickerViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
fontPicker.delegate = self
fontPicker.dataSource = self
fontPicker.selectRow(0, inComponent: 0, animated: true)
}
let fonts: [FontFamily] = [...]
var currentFont: FontFamily = FontFamily()
func numberOfComponents(in pickerView: UIPickerView) -> Int {
1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
fonts.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
fonts[row].title
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
currentFont = fonts[row]
}
}
【问题讨论】:
-
请提供代码示例
-
更改您的设备主题。
标签: ios swift uipickerview simulator