UIPickerView 在 iOS4 中导致崩溃

发布于 2024-10-03 23:51:36 字数 451 浏览 0 评论 0原文

我有一个简单的标签栏应用程序。直接从标签栏模板构建。当我测试该应用程序时,我注意到该应用程序有时会崩溃。在确定正确的顺序后,我发现如果我这样做,应用程序将会崩溃:

  1. 运行应用程序。打开上面有 UIPickerView 的视图。
  2. 打开另一个视图。
  3. 点击主页按钮(这会将应用程序发送到后台)。
  4. 再次点击应用程序图标,将其置于最前面。
  5. 点击其中包含 UIPickerView 的视图。
  6. 碰撞!

检查控制台显示: -[UIPickerView setFrame:]: 无效的高度值 130.0 固定到 162.0

我使用的 UIPickerView 是自定义尺寸。我在高度上使用比例 0.8f 的变换。所以如果你计算0.8*162.0确实是129.9f(控制台提到的130)。

我不知道如何解决这个问题。有什么想法吗?

I have a simple tabbar app. Built directly from the tabbar template. As I test the app, I notice that the app sometimes crash. After pinpointing the right sequence, I found out that the app will crash if I do this:

  1. Run app. Open the view that has a UIPickerView on it.
  2. Open another view.
  3. Tap home button (this will send the app to background).
  4. Tap the app icon again to bring it at the front.
  5. Tap the view that has the UIPickerView in it.
  6. Crash!

Checking the console shows:
-[UIPickerView setFrame:]: invalid height value 130.0 pinned to 162.0

The UIPickerView I use is a custom size. I use transform of scale 0.8f on the height. So if you calculate 0.8*162.0 is indeed 129.9f (130 as mentioned by the console).

I have no idea how to fix this. Any ideas?

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

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

发布评论

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

评论(1

意中人 2024-10-10 23:51:37

问题解决了。看来当应用程序进入后台时,UIPickerView需要再次查找其组件资源。它根本与 UIPickerView 的大小无关。

我为 UIPickerView 组件使用了图像,因此在使用这些图像填​​充 UIPickerView 后,我释放了之前分配的所有图像。如果要在 iOS4 中运行,则不得发布这些图像。

仅当应用程序结束时才释放它们。

The problem is solved. It seems when the app goes to the background, UIPickerView needs to find its components resources again. It is not about sizing of UIPickerView at all.

I used images for the UIPickerView components, so after I populate the UIPickerView with these images, I released all the images that were allocated earlier. These images must not be released if it were to work in iOS4.

Only release them when the app ends.

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