views:

40

answers:

1

I created a UITableView similar to the iOS address book that allows you to pick an image on one row and and there are additional custom cells that have text fields for entering data. I run into this problem only after loading a large image and get a memory warning in the console:

Received memory warning. Level=1

I load the image using the UIImagePickerController in a modal view.

So, when the memory warning occurs, my parent tableviewcontroller does a viewDidUnload, which is empty:

- (void)viewDidUnload { }

Once I close the modal view (choosing the image), the tableview reloads data and everything appears fine...However, scrolling does not work properly. The behavior is very odd: The scrolling will not stay past a certain point. I can literally pull the scrolling down all the way, but as soon as I release, the scrolling bounces back up and hides the bottom fiew cells (which appear normal).

For the life of me I cannot figure out what is going on, why this only occurs after a memory warning.

This is only happening on my iPhone (testing with iPhone 4). This further leads me to believe the memory warning is probably the root of my problem.

A: 

Everything you set up in [loadView] or [viewDidLoad] should be cleaned up in [viewDidUnload]. And the other way around: everything you destroy in [viewDidUnload] should be re-created and re-initialized in [loadView] or [viewDidLoad].

You should treat it as a secondary init/dealloc sequence.

Philippe Leybaert
I do this now, so my viewDidUnload sets objects to nil that were allocated in viewDidLoad, though this is great advise, unfortunately doesn't fix the scrolling lock issue.
Kevin
Beware: setting an object to nil doesn't release it.
Philippe Leybaert