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:
- Run app. Open the view that has a UIPickerView on it.
- Open another view.
- Tap home button (this will send the app to background).
- Tap the app icon again to bring it at the front.
- Tap the view that has the UIPickerView in it.
- 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?
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.
Your problem has been fixed by another guy with a radical approach. See this post'sanswer provided by a guy named bhavinb.
精彩评论