UIPickerView 作为 inputView 在方向改变时变得混乱

发布于 2024-12-07 07:20:50 字数 250 浏览 4 评论 0原文

我使用标准 UIPicker 视图作为 iPhone 应用程序中文本字段的 inputView。当视图以横向或纵向加载时,选择器的大小与相应键盘的大小相同。但是,当您在视图内旋转设备时,选择器不会正确调整其高度大小,就像调整其宽度一样。我设置了 UIViewAutoresizingFlexibleWidth。当我尝试设置 UIViewAutoresizingFlexibleHeight 时,选择器在旋转时会变得混乱(图形不连贯,组件被切断),尽管高度是正确的!有没有人弄清楚这一点?

I'm using a standard UIPicker view as an inputView for a textField in an iPhone application. When the view is loaded in either landscape or portrait, the picker is sized the same as the appropriate keyboard. However, when you rotate the device once inside the view the picker doesn't resize it's height properly, like it does with it's width. I have UIViewAutoresizingFlexibleWidth set. When I tried setting UIViewAutoresizingFlexibleHeight as well the picker gets messed up (choppy graphics, component cuts off) on rotation, though the height is correct! Has anyone figured this out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

十年不长 2024-12-14 07:20:50

我发现如果您使用的是 iOS 7,只需添加:

pickerView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

这解决了我的问题。过渡不是很断断续续,看起来“应该”看起来。

I found that if you are working with iOS 7 simply add:

pickerView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

This solved the problem for me. The transition isn't very choppy, looks like it "should" look.

○闲身 2024-12-14 07:20:50

我找到了一个创可贴:

在托管视图控制器的 didRotateFromInterfaceOrientation: 中,在该选取器视图上调用 setNeedsLayout 。奇怪的布局故障在旋转过程中是可见的,但在最后清理干净。

I found a band-aid:

In didRotateFromInterfaceOrientation: in your hosting viewController, call setNeedsLayout on that picker view. The weird layout glitches are visible during the rotate but clean up at the end.

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