How do storyboard controller display a toggle container?

Is there a way for the history bar to have a custom container view controller that behaves very similarly to UITabBarController

?

My container controller is similar UITabBarController

in that:

  • it switches screen content
  • in response to user actions with some widgets

But it differs from the UITabBarController

fact that:

  • it only toggles part of the screen (materialized by a rectangle border on the screen)
  • user action to start the switch includes specific UIControl

    instead of the tab bar at the bottom of the screen.

Also, I would really like the UITabBarController

storyboard of my application to be very similar to the storyboard:

  • One scene represents a container view with all content not toggled
  • As many childish scenes as I have the ability to switch content for the frame.
  • One transition from each toggle control to the corresponding child scene.

However, I was unable to achieve this. Is there a way (better than perhaps artificially making my subclass container display controller UITabBarController

)?

+3


source to share


1 answer


As far as I can tell, this is one area where storyboarding is far less useful than it should be.

From what I can see, you can manually remove all of your switch widgets, bind them to their respective target view controllers, and configure the resulting segments as instances of custom subclasses UIStoryboardSegue

that override (s) perform

and optionally implement prepareForSegue:sender:

in your container view-controller ... but (a) you probably already figured it out and (b) for me, which is unlikely to be like what you are aiming for in the first place.

For this and other reasons I (and would do it this way) avoid storyboards in such a scenario altogether and instead use NIB in conjunction with IBOutletCollection

(not supported in storyboards - you can't wire anything to them!) For view controllers.

In my case, I could then dynamically populate the segments UISegmentedControl

or rows UITableView

using the header / image properties of the tabBarItem

connected view controllers.



This is a trade-off , however, as you lose the ability to customize transitions between your view controllers in IB. Also, it relies on an implicit contract that the view controller is properly configured tabBarItem

, which cannot be expressed in IB.

It didn't matter in my case, but your mileage can be very different!

Separating the layout and using the container into separate NIBs helped keep things simple.

+1


source







All Articles