UINavigationController strange pop animation - ios

I have a strange animation when I pop a ViewController on my NavigationController. Short video to illustrate: https://youtu.be/IMbIS7evLrs
The view controller structure is:
UITabBarController -> UINavigationControllers -> UIViewControllers
I push the new VC using this line in my UIViewController:
[self.navigationController pushViewController:tripVC animated:YES];
Where tripVC is a newly created UIViewController.
Then the pop happens when the NavigationController Back button is clicked. I've also tried calling the pop programmatically using
[self.navigationController popViewControllerAnimated:YES];
from within tripVC and get the same strange animation.
What's particularly odd is I've used this structure / approach on other apps and haven't had this problem. Am wondering if there's some strange segue code in my app / am missing some animation code?

It seems that the background image in the second VC is wider than the device screen. As this scene pushes in/out the normally hidden edge of the image is revealed briefly.

Yes, for my case #Paulw11 is right. Enable clipsToBound to your root view.

If you haven't given background color of self.view then also it may occur.
This is the second reason for strange animation for navigation.

Related

Blank screen after dismissing UIModalPresentationCurrentContext

I know there are other questions that address this, but none of the other solutions will work for this situation.
I have a UITabBarController that contains a UINavigationController as a tab root.
I'm creating another UINavigationController, with a UIViewController as its root view controller, and presenting it modally with UIModalPresentationCurrentContext. The UINavigationController that presented this one sets definesPresentationContext to YES.
I change tabs and come back to the first tab. Then, I dismiss that UINavigationController, and the screen turns white (I think that's because the UITabBarController has a white background.)
Other questions suggest using UIModalPresentationOverCurrentContext. And, yes, that does solve the white screen issue. But I can't use that because viewWillAppear and viewDidAppear aren't called on the presenting view controller. I have code that can ONLY be run from those places. So, UIModalPresentationOverCurrentContext is a no-go.
I also can't use UIModalPresentationFullScreen or UIModalPresentationOverFullScreen because I have to display the Tab Bar while presenting modal window.
I will either have to use UIModalPresentationOverCurrentContext and somehow figure out a way to trigger viewWillAppear and viewDidAppear, or I need to use UIModalPresentationCurrentContext and fix the blank screen issue.
Can anyone offer any advice? I'm banging my head on my desk and am about to break something... >:(

How to reset the Navigation Controller in Xcode 6?

Im working on an App for iOS, thats uses the navigationController to switch betweens views. I'm trying to return from to the root viewcontroller from the third view.
I have succeeded in the Main.Storyboard, with dragging a button from third to root view, but then the NavigationController just continues the stack.
Is it possible to make a command from third view, to return to root ViewController, without the NavigationController Bar showing the "Back" button and keeping track and without reseting any Bools.
If you want to hide the back button from the navigation bar.Then write the code in third view's viewDidLoad or in viewWillAppear-
self.navigationItem.hidesBackButton=YES;
And Now write the code in the body of the action button.Such as-
[self.navigationController popToRootViewControllerAnimated:YES];
Let me know if it works for you.Thank you
You can use the [UINavigationCobtroller popToRootViewControllerAnimated:] to close all the view hierarchy to the first but for the remaining issues you can find plenty of answers on SO.

Dismiss multiple view controllers at once (iOS 8)

So in my code, I have a Tab Bar controller. When you click one of the tabs, it calls this code to open up a new storyboard (for video capture).
NavController *NC = [[NavController alloc] initWithCaptureInput];
[self presentViewController:NC animated:YES completion:nil];
In this view, he records a video and then the storyboard presents the segue. In that view, the user can preview his video. When he click's a button the storyboard pushes him to the next view.
In that last view, I use to call this in iOS 7 to make the app go back to the initial view (before the current storyboard).
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
This worked fine but in iOS 8, the top view is dismissed, and during the animation, you see the video preview view. Its only when the animation is done that the video preview view is removed (as it should be).
Can anyone tell me how I can have my proper animation where the top view is removed and during the animation you only see the initial view? This could be done if the app was to remove all the views at the same time (animating them at the same time too).
Yes, I've noticed that behavior, too. Unwind segues (as described in Technical Note TN2298) appear to handle this more gracefully.
In the view controller that you want to unwind to, add a method that looks like:
// use whatever name most descriptively captures the functional purpose of the
// view controller that you are unwinding _to_
- (IBAction)unwindToMainMenu:(UIStoryboardSegue*)sender
{
}
Then in the IB scene that you are transitioning from, you can control+drag from the "dismiss" button to the exit outlets control (as shown in that technical note or as shown here or here) and choose your unwind segue. In my casual experimentation, when you perform the unwind segue, it would appear that you do not see the interim views briefly during the transition.

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.

Can you animate setRootViewController?

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.

Resources