Presenting full screen modal views from a UISplitView? - ios

Just looking for some advice. What is the best way to present a full screen modal view controller from a UISplitViewController (set as the root) ?

There's no difference presenting a modal view controller from a UISplitViewController that from any other UIViewController.
You simply call - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated.

Do you know how to make a full screen controller?
Do you know how to present a modal view controller?
Are you having any problem combining the two?
Try it and if you have a specific problem ask about that.

Related

Is it possible to segue from a modal view to a view that is not in the hierarchy on a Navigation Controller in swift?

On my main view in a NavigationController I have a button that brings up a new view modally to submit a post. I have a button to dismiss this view which brings the user back to the main view, however if the users proceeds to make a post, I want it to dismiss the view and proceed to a show the post in the Navigation controller.
The ideal effect would have the standard navigation controller's back button on the top that can bring the user back to the main view when they have finished looking at their post.
I have tried several different methods, but I tend to get an error stating "Warning: Attempt to present (The View I Want to Show) whose view is not in the window hierarchy!
Thanks for any info!
Yes, it's possible. This is the best way I've found to structure the app to allow this functionality.
RootViewController
UINavigationViewController
ContentViewController (your current "main" view controller)
You're basically going to create a new RootViewController that is going to contain your current UINavigationController as a child. I usually setup the window.rootViewController programmatically in the AppDelegate. I would also keep a global reference to it.
Have a look at Apple's documentation on this. Basically, the RootViewController code would look like this:
[self addChildViewController:navController];
navController.view.frame = self.view.bounds
[self.view addSubview:self.navController.view];
[navController didMoveToParentViewController:self];
Now, whenever you need to present a modal view controller, present it from the RootViewController, instead of the current/top view controller on the UINavigationBar. This allows you to manipulate the UINavigtaionController independently and you won't get the error you're seeing.
So present the modal view controller from the RootViewController, this covers the UINavigationController and its content (top view controller). Make any changes you need to the UINavigationController stack (push, pop, etc...) with no animation. When you're done dismiss the modal view controller (with animation) and it will show you're adjusted UINavigationController.
Hopefully, this all makes sense. It's kind of complex and hard to explain in text. :p
If you don't want to setup a RootViewController, you might want to try presenting the modal view controller from the UINavigationController, as that might have the same effect. From the view controller just do self.parentViewController.present.
The main thing you're trying to avoid is presenting a modal from a view controller and then removing that view controller (pop) before the modal is dismissed. The view controller that presents the view controller is responsible for dismissing it.
I finally got it all working (I'm still new to Swift) and the two comments on the question were very helpful. The most helpful of all was the top answer here's example on github.
Similar question

How to do a real transition with iOS instead of modal?

From what I understand, modal is sort of like a pop up presentation of a view controller? So that means that the view controller that is calling presentViewController is still there?
What is the proper way of transitioning to another view controller without it just being a modal popup? (Meaning it is not a parent-child relationship between the two, I guess)
I think you want to use NavigationController to push other ViewController. Sorry if i have wrong answer
This is guide about NavigationController for you
http://www.raywenderlich.com/113388/storyboards-tutorial-in-ios-9-part-1

Shrink view controller while presenting another

I want to modely present a view controller, and during the animation I want to shrink the presenting view controller. I saw a lot of apps doing this effect, its seams that the entire view controller including the navigation bar is shrieked.
I'm not sure how to approach this, and I will really appreciate any help about how to make this kind of effect.
here is an example from the mail app, you can see that when the compose view controller is presented, the other view controller is shrieked behind him:
If this was for iPad I would tell you to simply use an embed segue, or resize your modal container's superview, but since it is for iPhone that makes things trickier. Apple has said that modal presentation for iPhones is always supposed to be the whole screen, so I doubt they did theirs modally. They either made a custom segue type (I'm not sure how to go about doing that), or they simply are using a view and presenting that on the bottom portion of the screen, with a view inside of it to represent the navigation controller.
You can add a different viewController's view to the current view controller then call parentVC addChildViewController: and use it like that. Just use a toolbar instead of a nav bar and it should work fine.
I was looking to do the same and I found this answer by Brian Sachetta that explains how to accomplish it. The link posted in the answer didn't work for me but I found the sample he is talking about here

Get a reference to the currently visible view controller

I have a UIAlertView. When the user taps a button in the alert view I want to show a new UIViewController.
In order to achieve this I need to know which view controller is currently visible on screen because that particular view controller is the right one to present the new view controller.
The problem is that I have a complex hierarchy of view controllers in my app including a UINavigationController and a UITabBarController (among others). So I cannot simply use self.visibleViewController to get the currently visible view controller.
I have found a possible solution on Stackoverflow but I would like to find a neater solution without having to dig through the whole view controller stack.
UINavigationController has a property called topViewController.
Maybe it helps you.

ModalView Over SplitView with transition

My app should display a login modal view, and once authentified, redirect on a SplitView.
For now, i'm using the method that change the rootView in the app delegate. So, in the loginController, i do this :
[[[[UIAppDelegate window ] subviews] objectAtIndex:0] removeFromSuperview];
And after that, i load my splitViewController and place it in the rootViewController property.
It's working. But i would like to make a transition between the two views, and i've absolutely no idea how to make this happen.
Any clue ?
Thanks
see this question Best way to switch between UISplitViewController and other view controllers?
It seems that you should show login view as a modal view over split view

Resources