Reputation: 32207
I have a ViewController
(with navigation) that needs to show 7 different content layouts. I want to keep the same background and nav, the only thing that needs to change is the central UIView
.
If I have 7 different UIViews
on the same xib/storyboard, can I hide the ones I'm not using or will that ding performance?
Using segues
won't work either because they make a mess out of my custom navigation and animations.
Is there a better way to accomplish what I am trying to do? Thanks for suggestions
My design is too custom for using view controller containment
so I decided to mimic the idea with a custom UIViewController
and two UIView
s. It's not too bad and it works rather quickly.
Upvotes: 0
Views: 404
Reputation: 32207
My design is too custom for using view controller containment
so I decided to mimic the idea with a custom UIViewController
and two UIViews
. It's not too bad and it works rather quickly.
Upvotes: 0
Reputation: 19
Generally, it's a good idea to unload views that aren't visible, however, if your views aren't using too much memory (and/or cpu time) hiding them when they're not in use should work fine.
View controller containment is probably what you should be doing if each view has its own unique functionality (i.e. view 1 is a map, view 2 shows some about text, view 3 is an image gallery). UITabBar might be useful, but it depends on your app.
The performance hit would depend on your views' contents. If you haven't done so already, invest some time into learning how to use Instruments (apple's diagnostic tool). Watching the video titled "Optimizing App Performance with Instruments" in the developer resources would be a good start.
Upvotes: 1
Reputation: 6064
You should look into using view controller containment, then you can load your views from separate nib files and still provide your custom navigation and animations from your container view controller.
Note: This is only really supported from iOS 5.
Upvotes: 1