Type “myViewController” does not conform to protocol UIPIckerDataSource in Swift

前端 未结 5 723
盖世英雄少女心
盖世英雄少女心 2020-12-13 23:50

I just create a new class in Swift, it\'s called myViewController and it\'s a UIViewController. Now I\'m trying to make it a UIPickerViewDelegate

5条回答
  •  借酒劲吻你
    2020-12-14 00:41

    Fix-it in XCode 8.1 inserts a deprecated version of the method below if you're using Swift 3:

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return componentNumber
    }
    

    In XCode 10.0+

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return componentNumber
    }
    

提交回复
热议问题