I am new to ios and working on container view first time.I have a containerview in a Taskviewcontroller .The containerview contains four childs i.e. Viewcontroller A,Viewcontroller B,Viewcontroller C,Viewcontroller D.
These Viewcontrollers contains table view cells .When I click on the cells of ViewcontrollerA it opens AdetailViewcontroller,When I click on the cells of ViewcontrollerB it opens BdetailViewcontroller,When I click on the cells of ViewcontrollerC it opens CdetailViewcontroller,When I click on the cells of ViewcontrollerD it opens DdetailViewcontroller.
These View controllers have back
(Task) button (that comes by default due to navigation).This button is suppose to take to the previous Viewcontroller,like if it is on CdetailViewcontroller,then it should bring back to CViewcontroller).But this doesn't happen actually .In every case ,it brings back to ViewcontrollerA.I am not able to understand the reason.
Please help to fix this.
As your all view controller A, B, C, D are child view controller of task view controller and when you are navigating the navigation controller of task view controller is used as it is the parent of all four controllers.
So when you do popviewcontroller it goes back to task view controller(not to any child view controller specifically). And when task view controller is appearing it reinitialises all its child view controller which sets view controller A as default child of its container view.
If you want your desired result, add the child view controllers from code in viewDidLoad of TaskViewController.
Visit Add child view controller to current view controller
Related
From my navigation controller's root view controller Root
I want to push a view controller A
which then instantaneously presents another view controller B.
How can I do both at the same time with a single push animation?
(💡 The idea behind this is that view controller A allows for editing some content. If no content has been created, it needs to show view controller B first which allows the user to enter a title and then create the content.)
What I've tried:
When I do the following in view controller A's viewDidLoad() method:
if content == nil {
let createContentViewController = // instantiate new view controller instance
present(createContentViewController, animated: false)
}
UIKit also omits the push animation when animated is set to false – so I get no animation at all. When animated is set to true, I get a double animation (first push, then modal). 🙄
The reason you're having trouble doing what you describe is that you can't present View Controller B on View Controller A until View Controller A is part of the view controller hierarchy — and until you have pushed it, it isn't.
I would suggest, therefore, not using a presented view controller in this story at all. All you are really describing, it seems to me, is a View Controller A and its main view (View A) with a View B in front of it. That's something you can readily prepare between creating View Controller A and pushing it. View B can still contain a Dismiss button or similar to which you respond by sliding it off the screen, revealing View A.
If you really need a View Controller B for purposes of code organization, then have View Controller A be a custom parent view controller for View Controller B. A cool feature of that solution is that the whole thing can be configured in the storyboard using an embed segue. If we push View Controller A and you don't need View Controller B, you just hide View B before pushing.
I have a tabBarController with 5 tabs the third tab is a navigation controller with TableViewController as the root view controller.
When I press on a row on the table view it push a detail view (regular view controller) about the selected row.
The problem is first time parentViewController and presentingViewcontroller properties (in the details page) are set, all other consecutive both properties are set to nil.
EDIT
I created a single tab application with navigation controller same as the one in the picture but I did not disable auto layout in the storyboard, every time parentViewController is set correctly.
I believe this is a bug if you disabled auto layout.
You are neither creating a child view controller, nor presenting a modal.
(Pushing a detail view controller onto a navigation controller's stack is kind of like adding a child, but navigation controllers predate the parent/child view controller mechanism, so they don't use it.)
What you need to check is the navigationController property of your detail view controller. That should be non-nil if it was pushed onto a navigation controller stack.
this is the first time I am seeing this... it seems that when I trigger the segue to the settingsViewController xcode is loading 2 View controllers on top of each other. The View controller with the byDate and byCategory buttons is part of a page view controller and I don't understand why this is happening.
Here is a photo of my storyboard: the settings VC is the one above Add New Transaction and the summary VC loads view controllers as the DataSource of a UIPageViewController
Here is my result:
Any ideas?
I'm wanting to create a UI where I have a popover that comes from a button that and contains a split view UI with two table view controllers side by side.
The storyboard I have now has a normal page with a button, the button has a popover segue to a split view controller.
The split view controller has a master relationship to a navigation controller which has a root view controller of a table view controller.
The split view controller has a detail view controller to another navigation controller which again has a root view controller of a table view controller.
When I launch the pop up it only ever displays the master controller, not the two side by side.
UISplitViewCpntroller can only be the root view of an app - as such, you cannot put them in a UIPopover or any other non-root view.
You would have to create your own UISplitViewCpntroller type view (or look for some open source code).
In my app delegate I create a UISplitViewController. I set the delegate to be the detailViewController.
When I run my app in portrait, I have the left top popover button showing that will slide out the split view master.
Then I have a button in my detail view that resets the splitviewcontroller array with a new detail view controller and sets the split view delegate to that controller.
The second detail view displays properly... but I lose my popover button on the second view controller.
Does anyone know how I can get that button to remain on all of my detail view controllers I may add?
Thanks!
See http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=1546 for what I find to be a good approach.
It involves setting the SplitViewController delegate to be the master instead of the detail. The master keeps references to the popoverController and the button, and each time the delegate methods are called (hide and show master) it gets the current detail view and performs the necessary action (add in the button/remove button and popovercontroller).
The master defines a protocol for "SubstituableDetailView" which contains the two methods for showing/hiding the button.