问题描述
我尝试这样做:当单击按钮时调用 reloadAllComponents:
但它不调用 rowHeightForComponent:
I tried to do it in this way: call reloadAllComponents:
when button is clicked but it doesnt call rowHeightForComponent:
推荐答案
你不需要像 @auspicious99
建议的那样释放 pickerView 来设置新的单元格高度.而是在每次触发 reloadAllComponents 时设置委托或数据源,如下所示:
You don't need to release pickerView to set new cell height like @auspicious99
proposed.Instead set the delegate or dataSource each time you trigger reloadAllComponents like this:
pickerView.delegate = self; //or pickerView.dataSource = self;
[pickerView reloadAllComponents];
为什么 reloadAllComponents 方法不触发 rowHeightForComponent 方法真的很奇怪,但这看起来是使用上述技巧的有效解决方法.
It's really strange why reloadAllComponents methods doesn't trigger rowHeightForComponent method, but this looks like to be a valid workaround using above trick.
希望有帮助.
这篇关于如何通过单击按钮更改 UIPickerView 中的行大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!