Swift: Segue to a view programmatically from an alternate view - ios

I have a master view, I have added in a menu (TableView) that slides out on an IBOutlet. This menu is controlled by another view controller. The master view is segued to multiple other views but I am having huge problems segueing from the menu view (TableView) because it is in another view controller.
How can I segue from master view to another view from my table which is controlled from yet another view controller?
Note: I am also having to carry over some information from master view to the other views, but I when ever I have tried to segue from the menu, the new views error and tell me they unexpectedly found nil while unwrapping optionals.

Have your menu only post a notification when something is selected. Have the view controller that's the source of the segue (master?) listen for the matching notification(s) and perform the segue.

Related

UISplitViewController - Tapping on cell in master view controller causes segue in master view controller and not in detail view controller

I'm working to migrate an existing project with a standard table view to use the UISplitViewController methodology. The standard table view is also linked to a Tab Bar Controller.
The hierarchy is as follows:
Tab Bar Controller > SplitViewController > MASTER: NAVIGATION CONTROLLER > TABLE VIEW;
SplitViewController > DETAIL: Navigation Controller > TABLE VIEW;
When I tap on a cell in the master view controller, it causes a segue of the view I want loaded in the detail view area to be in the master view controller table view area. In essence, the detail view controller loads in the master view window area.
I've validated that all connections are made correctly, but I don't know why this is happening. Any insight would be appreciated!
Not sure if you ever got to the bottom of this or not but I just ran into the same issue and thought I'd explain how I fixed it incase anyone-else comes across it.
Basically make sure that the detail view controller is linked in your Split View Controller in the storyboard before linking the cells selection segue to the detail view controller.
Recreating the segue between the cell and the detail view controller was enough to fix this for me after I'd set the split view controller correctly.
Hope that helps,
Richard

parentViewController and presentingViewController both are nil

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.

iOS: Keeping UIToolBar on top during segue

I have a UIViewController which segues (push) to another UIViewController. The first controller contains a nicely laid out UIToolBar menu and I want this to persist over the secondary UIViewController (and another other ones I push on the navigation stack).
Is this possible?
This can be done with a container view in a storyboard, or using the custom container view controller api in code. In the storyboard, you can add your tool bar to a view controller, drag in a container view, and size it to take up the rest of the view. You will automatically get a view controller connected with an embed segue to the container view. Select it, and embed it in a navigation controller. You can use prepareForSegue (which will be called immediately after your main view controller - the one with the container view - is instantiated) to get a reference to the navigation controller (it will be the destinationViewController).

IOS Container View and Push Segue

I have a container view which is linked to a child view controller with embed segue and it is linked to another view controller(My View Controller) with push segue on a button.
My problem is; I can't display a subview that is added in container view in My View Controller with storyboard configuration like figure.
If I added one more same container view(Banner View Controller) before My View Controller, exists infinite loop.
How should i do to solve this issue?
I use Apple's TabbedBanner iAd With StoryBoard example.

Maintaining popover across multiple detailviews in UISplitView

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.

Resources