错误:
类型'GearViewController'不符合协议 'UIPickerViewDataSource'
基于apple documentation,UIPickerViewDataSource只需要2个方法。两者都包含在下面的代码中。我认为语法是正确的。 (但可能不是)
类/控制声明和init。 (为清楚起见,删除了许多其他代码。如果需要,可以使用完整代码,我会编辑。只是想保持简短。)
class GearViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate{
@IBOutlet weak var pickerGearCategory: UIPickerView!
override func viewDidLoad() {
super.viewDidLoad()
pickerGearCategory.dataSource = self
pickerGearCategory.delegate = self
}
委托和数据源
let gearCategoryPickerData = CategoryRepository.allCategories()
//MARK: CategoryPicker- Delegates and data sources
//MARK: CategoryPicker - Data Sources
//Required
func numberOfComponents(in pickerGearCategory: UIPickerView) -> Int {
return 1
}
//Required
func pickerGearCategory(pickerGearCategory: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return gearCategoryPickerData.count
}
func pickerGearCategory(pickerGearCategory: UIPickerView,titleForRow row: Int, forComponent component: Int) -> String? {
return gearCategoryPickerData[row].name
}
答案 0 :(得分:0)
numberOfComponents在哪里,但pickerView在哪里?
答案 1 :(得分:0)
您实施的协议方法之一是错误的,方法应该是:
func pickerView(UIPickerView, numberOfRowsInComponent: Int) {
//Your implementation here
}
您已将该方法实施为
func pickerGearCategory(pickerGearCategory: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
//Your implementation
}
纠正它,你应该好好去。
答案 2 :(得分:0)
只需添加vmask = ~np.in1d(np.arange(m*n),rm_idx[1] + n*np.arange(m))
out = arr.reshape(-1,p)[vmask].reshape(m,-1,p)
功能