UIPickerViewDelegate rowHeightForComponent 返回越界索引
我正在编写带有 3 个组件的 UIPickerView 的代码。我希望每个组件都有不同的行高。我有一个模型组件数组,每个组件都有属性 rowHeight
并且我实现了 pickerView(_:rowHeightForComponent:)
如下:
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
components[component].rowHeight
}
但事实证明参数 component
有时等于组件的数量,即在我的例子中有时等于 3。所以我实际上得到了一个超出范围的组件索引。有人遇到同样的问题吗?这是一个已知的错误吗?
I'm writing a code with a UIPickerView that has 3 components. I want each component to have a different row height. I have an array of model components, each has the property rowHeight
and I implemented pickerView(_:rowHeightForComponent:)
as the following:
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
components[component].rowHeight
}
but it turns out that the parameter component
sometimes equals to the number of components, i.e. in my case is sometimes equals 3. So I actually get a component index that is out of bounds. Did anyone have the same problem? Is it a known bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论