UIPickerView - 更改组件宽度

发布于 2024-09-13 12:31:54 字数 257 浏览 1 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戈亓 2024-09-20 12:31:54

仅仅重载是不行的。您还需要调用 setNeedsLayout

[pickerView reloadAllComponents];
[pickerView setNeedsLayout];

Just a reload won't work. You also need to call setNeedsLayout

[pickerView reloadAllComponents];
[pickerView setNeedsLayout];
—━☆沉默づ 2024-09-20 12:31:54

您可以使用[pickerView reloadAllComponents]。

更新:

这很奇怪。您还可以尝试检查以下内容 解决方案

You may use [pickerView reloadAllComponents].

Update:

That's weird. You may also try to check the following solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文