I have an application that takes you through multiple steps (5-6 steps) that at the end of it you will have a newly registered account. I am using a storyboard and a lot of these steps have very similar (or identical) layouts and objects and elements within them. Right now what I am doing is simply creating a new View Controller for each of these steps and then altering the data within them to pertain to the specific step. When I look at my storyboard, I feel like their has to be a way to optimize this so that I don't have so many identical view controllers beside one another.
As you can see there are 5 view controllers that are almost identical and I am looking for a way to condense these to a single view controller or perhaps 5 view controllers that access a single view which contains the variety of elements you see in the image. Any help would be greatly appreciated. Thanks in advance!
If your all view controllers' look is same then no need to create multiple view controllers.
You can only create one view controller and change view or content of view as per requirement.
Hope it helps
Related
In my current app I have a tableview that I would like to display on multiple view controllers, I know I could copy and paste the code from one view controller to another but I know enough about coding techniques that copying and pasting large sections of code is bad practice but not enough to know a way to avoid it in this current situation. I am using swift 3 and a standard table view. Does anybody have any good suggestions for me?
If you're using interface builder, you can create a view controller with only your tableview in it and "embed" it in other view controllers using a container view.
IB will create a new embedded view controller when you add the container view but you can delete that and relink the container view to the one containing you tabelview.
I have been searching for this solution for a while now, and all the tutorials are hard to follow or they are too specific, so I wanted to ask this question in general terms so it would be easy to implement. I have two separate View Controllers in Xcode (using Obj-C), and I would like to have the second View Controller be animated on top of the first by dragging down anywhere on the screen while having the first view controller stay where it is.
So far, I have tried to cram all this into one View Controller, but this is not practical as there are two different scenes and having two controllers would be a better solution.
Also, if anybody knows how to animate the first controller while the second is sliding over it that would really be a nice addition!
I guess you want to implement Container-Containment view controllers. Here you use parent/child relationship and one view controller can hold many child view controllers. We move child controller to parent position based on criteria.
Hope it helps!
I'm trying to build an interface that has two horizontally scrolling collection views, but I'm still torn between having two separate view controllers control their respective views or controlling the two views within the main view controller.
People, at least in the past, have said having a controller that controls only a fraction of the screen is not good practice. But I also have a feeling that's only a relic of pre-iOS 5 days.
The thing with controlling two rows of collection view is the data source object, in this case the main view controller, gets very confusing and it's hard to pass on data to subviews of collection views because I have to check which collection view is sending the message and such.
I asked a similar question in the past but the thread got blocked or something. Please don't. I don't see anything wrong with the question and I've been pulling my hair for so long.
Thanks
After a lot of hair pulling and experiments, and reading posts about table views embedded in other table views, it seems that the best way to do it is have one main view controller control all the subviews.
I tried adding collection view controllers as child view controllers, and setting the frame and layout and everything, but they will always end up weird. It does seem Apple doesn't allow for view controllers to control only a small portion (I may be wrong, but based on my experience with UICollectionViewController this is the case).
The problem with identifying which view is which in the data source methods, you can use the tag property.
I'm new at objective-c programming and I need help clearing some doubts about the split view controllers. I understand that if you use a split view controller in your app then it must necessarily be your root view and I was wondering if there was any way to get around it.
I mean, I need to use split view controllers in my app but only in a couple of views, and for the rest just use simple views. If anyone has any idea or suggestion as to how to do this I'd be really grateful.
There are several things you can do. You can present your simple views modally, which will cover up the split view controller, or you can switch out the window's root view controller when you're done with the split view. Which to do depends on how and where in your app you use the split view. If you are going back and forth to it, then I would use the first method, if you're using it once, then going to the simple views, I would use the second method.
You can add split view controllers as children of tabbarviewcontrollers. Also, you can add split view controllers into container view controllers you build.
I am exploring the design options for an iPAD application with multiple views on the different part of the main screen. I am going to have different ViewController for each of the view. UI is quite different from what any of the available view controllers (UISplitViewController, UINavigationController etc.) provide. I have been reading about the container extension api of UIViewController (especially addChildViewController):
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html
(Look for "Implementing a Container View Controller")
However, it seems to me that this functionality is mainly designed for applications with UI that transition from one view to another (transitionFromViewController...). In my case, all of the views are visible at the same time. However, they do interact with each other. So my questions:
Am I missing something w.r.t. container extension of View Controller? I will still probably end up using this just to keep the list of child view controllers but don't see much value.
Can you recommend any other api/pattern that I should be using?
Thank you.
You can easy access to childViewController.
self.childViewControllers will return an array with all childs.
I asked similar question couple days ago: Maybe this will help you:
Get container VC instead of view
Take a look at http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html.
Add your various view controllers to self.childViewControllers and add the views of the child controllers as subviews of self.view.