I am working on a photo gallery app. Root view is a navigation controller which takes the user to the thumbnail view. Tapping any thumbnail takes the user to PhotoView which shows the tapped image in full screen.
Below is what I have done in my PhotoViewController:
The approach is pretty much similar to the ScrollingMadness project which I found at github.
I initialize a UIScrollView and add it as a subView to my view controller's view. Set some basic properties of UIScrollView. Add images to UIImageViews (5 in numbers). Add all these imageViews as a subview to UIScrollView. When zoom operation is performed on any image, all the image subviews but the current one are removed from the scroll view. When the image zooms out back to the minimum scale, all the images are added back to the UIScrollView.
As explained in the sample code from Apple, I am using TapDetectingImageView delegate to create the imageViews and handling touch events.
When I run the app, everything works fine in simulator. No issues whatsoever. But when I run the app in device, it crashes after I scroll to 3rd or 4th image. While debugging I found out that didReceiveMemory warning is called after I scroll to 3rd or 4th image. I run the app using Instruments. The object allocations shows allocation levels to only 1.5-2MB when the crash happens. I believe memory usage to this level is very normal ... right?
Anyone who experienced this before OR any input as to how I can get rid of it... would be all the help I need in world at this time.
Let me know in case you need any other info.
PS > Its frustrating to see the whole app perfect in simulator but crashing in the device :(