Can you animate setRootViewController? - ios

I'm using a SplitViewController which can't be part of a navigation controller. I'm using SetRootViewController on an IBAction, which is fine, but it's not animated. Ideally I'd like to use the same animation as the Navigation Controller does (slide in from the left/right) but if that's not possible I'd like to use a consistent animation when ever I need to do this.

I'm not sure about this, but I would suggest the following.
Set the UISplitViewController as your UIWindow's rootViewController. In the viewDidLoad, you make a presentModalViewController:animated: call with the button's UIViewController as modal. Make sure you don't animate it. This gives you the illusion that the modal view is the first you see when the app launches.
When you push the button, you animate the button's UIViewController out with dismissModalViewControllerAnimated:. Now you can choose how to animate. One of your choices is cross disolve.

Using iOS 5.0 you will be able to use presentViewController:animated:completion to present the SplitViewController from your initial rootViewController.
Prior iOS 5.0 your only chance is using the transitionFromView:toView:duration:options:completion method on the rootViewController's view, which means you will have some effort with passing several messages to your SplitViewController manually. iOS prior 5.0 does not support container ViewControllers.
But probably you want to rethink your design.
You should set the SplitViewController as rootViewController initally. On App startup (or whenever you need to) you should present your LoginViewController modally.
When the user logs in successfully, you hide your modal view with whatever animation you want to choose.
Since the SplitViewController is your main ViewController it should be the rootViewController of your application.

Related

Call pushViewController after presentViewController in Swift

Is it possible to somehow call pushViewController after presentViewController was called in Swift?
Or at least I need to implement the same behaviour when new UIViewController appears from the left side. The only option that I got to develop was to fake pushViewController with CATransition() but in this case the mechanism of new UIViewController appearance is different from the native.
When you use native pushViewController new UIViewController appears over old one with fade.
When you use faked presentViewController while new UIViewController appears previous just moves out of the screen.
I also tried to use segue but in this case new UIViewController appears from bottom.
So I prefer just to call pushViewController after presentViewController if it is possible.
Thanks.
You need use a UINavigationController and set it's rootViewController to the UIViewController you want to present (from the bottom - as a modal).
Call presentViewController on that UINavigationController.
Then you can call pushViewController to push UIViewControllers onto the navigation stack and it will slide in from the side instead of the bottom.

iOS 7 universal background UIViewController

I am trying to set up a UIViewController in my app which always remains in the background of all other UIViewControllers. What I want it to do is display a repetitive animation continuously in the background, unaffected my transitions and navigations in the UIViewControllers in the foreground. Can anybody suggest a good method to do this?
You could create your own UINavigationController and add your animation view to its background in the viewDidLoad method
self.view insertSubview:myAnimatedView atIndex:0
And make sure that your other viewcontollers are transparent.
See also https://stackoverflow.com/a/13096911/443270
Make a view controller that will have your background view and animation as your root view controller. Then make the view controller that you want to control the rest of your app (we'll call it your navigation controller). Add the view of your navigation controller as a subview of your background view controller.
edit:
You can't do this with tab bar controllers as they must be the root view controller.
start with a subclassed UINavigationController with your animation on ViewDidLoad
push the viewcontrolelrs on this subclassed NavController
example from my github page
https://github.com/mako34/backgroundNavController

Present UISplitViewController in UITabBarController app by UIButton

I have a UISplitViewController which is called by the tap on UITabBarItem. Everything works fine unless I need to call the UISplitController from the other places in my app by clicking on cell for example. I can't push it or present it modal.
Is there a way to do this ? I know that the design of the app is not perfect but I can't change it unfortunately. So I need to present the UITabBarViewController by pressing some element on other tabs of the app.
you can not push or present uisplitviewcontroller because it must be as root of application.you can create custom splitview using your custom view controllers
up to my knowledge that i know....

Disabling rotation for ViewController in NavigationController

Is it even possible to disable rotation when the View Controller I want to disable it in is
in a Navigation Controller that supports all directions? for one special view I want only portrait mode to be allowed, I´v tried about everything but nothing seems to work - I am guessing this is cause the View Controller is part of a Navigation Controller with segues?
By Default any property or a setting of a Super View is applied on all the sub-views inside it. Therefore even if you block the View Controller it will rotate because it is in Navigation Controller that allows rotation. Therefore i would suggest that you create a property in your AppDelegate that sets the orientation settings and then haldle it from ViewControllers

ViewController to NavigationController and back

I have one problem for which im not sure how to solve. Currently i have main UIViewController with some buttons. This is the initial view that is created with app. On it, one button calls storyboards segue with style Modal on ViewController which is part of UINavigationController. After that few other viewcontrollers are handled within the UINavigationController via segues and getting back via navigationController:popViewControllerAnimated. What i dont know is how to get back from UINavigationController to first UIViewController. I tried, when I'm on first one on navigationctrl,
[self removeFromParentViewController];
yet that only removes the view but it seems that UINavigationController somehow stays alive as result is black screen. Creating unconnected segue and call it from code would be possibility, but im not sure if that is the proper way. Would that leave navigation controller alive ?
Is there any reason you are using a UIViewController first and THEN a UINavigationController?
Why not change this so that the UINavigationController is the initial view controller and then drive everything from there.
If you want the first view to not have a nav bar then you can hide it easily.
That way you can move around through all views by popping and pushing through the UINavigationController.

Resources