如何通过单击按钮更改 UIPickerView 中的行大小? [英] How to change the size of row in UIPickerView by button click?

查看:24
本文介绍了如何通过单击按钮更改 UIPickerView 中的行大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试这样做:当单击按钮时调用 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 中的行大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆