GeneCode
GeneCode

Reputation: 7588

UIPickerView Causing Crash in iOS4

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?

Upvotes: 0

Views: 1650

Answers (1)

GeneCode
GeneCode

Reputation: 7588

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.

Upvotes: 1

Related Questions