UIViewControllers and UIViews ... how to create simple applications

I'm a little confused about how many controllers I need, and when I can load UIViews into the same controller, and also have two controllers for two separate UIViews.

Here is my current situation. I have a simple application that receives information on the home screen, and then based on information from the user (via UIPicker and text field), it displays flip animation for a new view, which is one of two options: ViewA or ViewB.

Now I have a GenController.view root controller that loads into UIWindow after starting. Then in GenController, in the ViewDidLoad method, I instantiate another GetInfoController and insertSubview in self.view, which is currently the original instance of GenController.

getInfoController receives information, executes some logic in user records, and then loads either an instance of ViewAController or ViewBController respectively.

ViewAController and ViewBController are very similar, but only UIView looks a little different. User interactions with the screen will be the same.

It seems to me that 1) GenController and GetInfoController should be the same, but I'm not sure how to integrate them. Upload GetInfoController directly to UIWindow? Do I need to do something in ViewDidLoad? 2) should I have one viewXController instead of one for ViewA and ViewB? ... How to load different UIViews into one controller based on logic in GetInfo?

+3
source share
1 answer

Sounds like you want to use it UINavigationController. It supports multiple UIViewControllers and allows you to easily switch between each other.

Typically, one UIViewControllersupports one UIView. (Therefore, the 'view' property in the class UIViewController.)

UIViewController, UIViewController, - :

[self.navigationController pushViewController:secondViewController animated:YES];
+3

Source: https://habr.com/ru/post/1706421/


All Articles