Take the 2-minute tour ×

As title says, I'm wondering if stacking subviews can slow down an iPhone application.

For example, I have a UIViewController, which has a view occupying the whole screen. When the user presses a button, I create a second view controller and add its view as a subview of the original VC, making the second view completely hide the first one.

Does the application have some kind of automatic optimization which would be something like "ok, I know what to draw for every pixel of the screen, I stop seeking for subviews" ?

If not, I don't think stacking 2 full-screen views can really slow down the app, but could 3, 4 or more views be problematic if they include many subviews themselves (labels, images)?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Read the View Controller Guide sections on Modal View Controllers and memory management. Prefer to use modal Views instead of subviews when you want to present a new screen temporarily and a UINavigationController for "drill-down" views.

share|improve this answer
Thanks for the link to the guide. I think Combined view controllers is better for me though, as my app is already something like this, it has a tab bar controller, and each tab has its own navigation bar. –  Jukurrpa Jul 6 '10 at 17:35
add comment

You can always set UIView#hidden = YES on the views not seen. That should prevent redraws.

share|improve this answer
That can be useful too. Thanks. –  Jukurrpa Jul 8 '10 at 0:28
add comment

This is largely dependent of what the subviews contain and what is the total memory load of the app. Memory is very crucial for devices like iPhone and you should never keep the things which you don't require. When you are adding many subviews without releasing any, your memory requirement obviously will increase. This may slow down the app, even may crash the app. Stacking of two may not be a problem, but stacking many is not a very good design.

So the summary is you should always check the memory load of the app through instrument and always properly respond to memory warnings.

share|improve this answer
Right, I did not think about the memory usage, which is crucial as you said. I'll try to find a better way to do. –  Jukurrpa Jul 6 '10 at 17:38
add comment

Your Answer


