简体   繁体   中英

Presenting an UIViewController's view from another UIViewController

I have a tricky question. As everyone knows, Apple clearly says that ONE UIViewController should be onscreen at a given time.

But how about if you wanna implement a signup worflow, with tiny views, of say... 200px height?.

Is it there any real problem you could face.. if you attach an UINavigationController (320x200px) as a subview, and push several UIViewControllers?.

If i go the UIView approach, i'll need to replicate the UINavigationController's behavior. It's not big deal, but it takes extra time.

Furthermore, UIView's shouldn't have business logic code. So, the rootViewController would be handling the whole signup flow. Which is OK, but i'd really rather split it up into several classes.

Any suggestions will be very welcome. Thanks in advance!

You should look into the new container ViewControllers. From Apple's Docs:

Implementing a Container View Controller

In iOS 5.0 and later, custom UIViewController subclasses can also act as container view controllers. A container view controller manages the presentation of content of other view controllers it owns, also known as its child view controllers. A child's view can be presented as-is or in conjunction with views owned by the container view controller.

See also https://developer.apple.com/videos/wwdc/2011/?id=102

I suggest keeping with 1 view controller and just pushing the views. You could also do something like using a TableViewController with custom cells that you scroll through for each part of your workflow, same with a scroll view might work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM