UIPickerView - 更改组件宽度
在我的 iPhone 应用程序中,我想要一个包含 2 个组件的 UIPickerView。最初,左栏较宽,右栏较窄,以使左侧的文本易于阅读并从中进行选择。
选择此列后,用户将单击右列以从中选择一项:发生这种情况时,我想调整列的大小,使左列变窄,右列变宽,以便所有文本都可以显示读。
我一直在尝试“pickerView widthForComponent”,但这似乎只在视图最初加载时才会被调用。
有什么方法可以动态调整列的大小吗?
谢谢
In my iPhone app I want to have a UIPickerView with 2 components. Initially the left column will be wide and the right column narrow to enable the text on the left to be read easily to allow selection from it.
Once this column has been selected the user will click on the right column to select an item from it : when this happens I want to resize the columns so that the left column is narrow and the right one is wide so that all the text can be read.
I have been experimenting with "pickerView widthForComponent" but this seems to only get called when the view is initially loaded.
Is there any way I can dynamically resize the columns ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅仅重载是不行的。您还需要调用 setNeedsLayout
Just a reload won't work. You also need to call setNeedsLayout
您可以使用[pickerView reloadAllComponents]。
更新:
这很奇怪。您还可以尝试检查以下内容 解决方案。
You may use [pickerView reloadAllComponents].
Update:
That's weird. You may also try to check the following solution.