且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UIPickerView 导致崩溃

更新时间:2023-02-02 13:16:11

我的应用遇到了类似的问题.IIRC,作为数据源的数组已被弱声明,并且正在被释放,因此在接收到 didSelectRow 时数组计数为 0(声明它为强数组解决了问题).正如 Rohan Kapur 所指出的,有一个与从该方法返回 0 相关的错误.

I had a similar issue with my app. IIRC, the array that served as the data source had been declared weakly and it was being released such that the array count was 0 when didSelectRow was received (declaring it as strong resolved the issue). As noted by Rohan Kapur, there is a bug related to returning 0 from that method.

我建议在 numberOfRowsInComponentdidSelectRow 的开头记录数组计数,以确保类"确实包含您期望的内容.

I would suggest logging the array count at the beginning of both numberOfRowsInComponent and didSelectRow to ensure that "classes" really contains what you expect.