gpt4 book ai didi

ios - 简单的 UIPickerView 错误

转载 作者:行者123 更新时间:2023-11-30 13:35:11 25 4
gpt4 key购买 nike

我在 myPicker.dataSource = self 线上收到以下错误。有谁知道这是为什么或者我可以做些什么来解决它?

Threat 1:EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP, subcode=0x0)

这是代码:

import UIKit

class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet var myPicker: UIPickerView!
@IBOutlet var textFIled: UITextField!

let pickerData = ["Mozzarella","Gorgonzola","Provolone","Brie","Maytag Blue","Sharp Cheddar","Monterrey Jack","Stilton","Gouda","Goat Cheese", "Asiago"]

override func viewDidLoad() {
super.viewDidLoad()
myPicker.dataSource = self
myPicker.delegate = self
}

func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData.count
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[row]
}

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
textFIled.text = pickerData[row]
}
}

最佳答案

当您的 IBOulet 未正确连接到 Storyboard中的 UIPickerView 时,就会发生这种情况。删除所有连接并重新连接。

关于ios - 简单的 UIPickerView 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36164665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com