Reputation:
When you use UIPageViewController
you get the full presenter life cycle for the ViewController you present. When you are on page one and insert a new UIViewController all life cycle methods of this new view controller are called. This is great to create and release objects to release memory.
When you use UISegmentedControl
you don't have such things. Assume you have a UISegmentedControl
with two tabs. Each tab represents a long list of items. Keeping each list of both tabs in memory does not seem to be a good memory use.
How do I handle the content of different tabs of a UISegmentedControl
?
Upvotes: 1
Views: 441
Reputation: 13343
As said by @Duncan C, you might be confusing UITabBarController
with UISegmentedControl
.It is a View, it does not managed view controllers or tabs.
Either way, UIPageViewController
and UITabBarController
are container view controllers and will manage their child view controller efficiently.
Your own view custom controllers are the ones you should design to be memory efficient.
Upvotes: 0
Reputation: 131481
A segmented control does not manage view controllers. It simply lets the user select one of several values.
Are you thinking of a tab bar controller? If so then you're right that it creates all of the child view controllers that it manages and then keeps them around.
You may be engaging in premature optimization. If your controller is managing very large amounts of data then you may want to set it up to release that data on viewWillDisappear and load it in viewWillAppear. Bear in mind though that large amounts of data means megabytes of data on modern devices. You can basically load unlimited amounts of text and not worry about it. Only multimedia content really amounts to a significant amount of data.
Upvotes: 1