第一次问一个问题,如果我忘记了什么,请坚持我。
所以我有一个带有tapRecognizer的UiPicker。当用户点击时,我正在更新点击的行的颜色,理想情况下,希望在点击时重新加载以立即更新颜色。但是,由于某种原因,此脚本会自动滚动到选择器的顶部。
在重新加载组件后立即选择行几乎可以用,但是仍然有大约50%的时间滚动到顶部。
我在其中玩得很开心,但是在不自动滚动到顶部的情况下无法找到一种方法来实现ReloadAllComponents或ReloadComponent。 任何人都知道它在哪里被破坏了吗?
谢谢
Uncaught SyntaxError: Unexpected token < runtime.js:1
Uncaught SyntaxError: Unexpected token < polyfills.js:1
Uncaught SyntaxError: Unexpected token < styles.js:1
Uncaught SyntaxError: Unexpected token < vendor.js:1
Uncaught SyntaxError: Unexpected token < main.js:1
其他代码
@objc func pickerTapped(tapRecognizer: UITapGestureRecognizer) {
if tapRecognizer.state == .ended {
let rowHeight = self.RightPicker.rowSize(forComponent: 0).height
let selectedRowFrame = self.RightPicker.bounds.insetBy(dx: 0, dy: (self.RightPicker.frame.height - rowHeight) / 2)
let userTappedOnSelectedRow = selectedRowFrame.contains(tapRecognizer.location(in: self.RightPicker))
if userTappedOnSelectedRow {
PickerNumber = self.RightPicker.selectedRow(inComponent: 0)
if(pickerSelectedData.contains(pickerData[PickerNumber]) != true){
pickerSelectedData.append(pickerData[PickerNumber])
pickerSelectedD[PickerNumber] = 1
}
else{
if let itemToRemoveIndex1 = pickerSelectedData.index(of: pickerData[PickerNumber]) {
pickerSelectedData.remove(at: itemToRemoveIndex1)
}
pickerSelectedD[PickerNumber] = 0
}
RightPicker.reloadAllComponents()
RightPicker.selectRow(PickerNumber, inComponent: 0, animated: false)
}
}
}
再一个
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
RightPicker.reloadAllComponents();
}