Presenting UIViewController causes strange behaviour - ios

When presenting a UIViewController using
[myUINavigationController presentViewController: paypalViewController animated:YES completion:nil];
The new controller displays fine, but when it is dismissed the navigation breaks in the whole app. Pushing screens after this point using 'pushViewController' seems to push the view because I can 'click' buttons on the screen, but the UI itself does not update.
The strange thing is, that presenting the view as above does work from certain screens but not others. I have tried setting the UINavigationController on the screens that don't work to a strong variable, but that didn't work either.
Any ideas?

Related

UINavigationController strange pop animation

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.

View controller will dismiss without any animation when come back from background

App on iOS6 and my iPhone is 4S, I present view controller using Storyboard and dismiss with following code:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
It works fine until my app went to background and then come to foreground again, I present a view controller and dismiss it. The view controller will dismiss without any animation. I know it's a small problem but it did confuse me.
Is that a bug of iOS6 SDK?

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.

Multiple MODAL VIEW controller change base modal to FULL SCREEN after ROTATION

This has been troubling me for quite a while, and I have done so much research on this, but could't find an answer. My first time posting a question here, please correct/forgive me if I make a mistake.
Environment: iPad, iOS 6.0
Problem: Base modal view change to full screen after rotation.
Description: I have a full screen application running currently showing a modal view controller. From the showing modal view, I display another modal view by doing:
vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:vc animated:YES];
//[self presentViewController:vc animated:YES completion:NULL];
While the second view is appearing, and I rotate the iPad device. The base(first) modal view becomes full screen, and the topmost(second) modal view stays in formSheet style. (rotate correctly)
I can fix this by adding modal view to navigationController, but I want to keep it in modal view.
Any one knows a fix? I believe this person here is having the same problem:
ios 6 Incorrect modal view size after rotation
Btw, everything works fine in iOS 5. Apple changed the way rotation works in iOS 6.
Thanks,
-peter
I found a solution for this problem. Set the last modal view's presentation style to UIModalPresentationCurrentContext before you present it.
Like this:
vc.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:YES];
This solves the base modal view change size after rotate the iPad screen.
Originally answered by people on Apple Dev forum.
I had the exact same issue and used the code in iOS 6: Parent modal's modalPresentationStyle ignored after rotation worked like a charm

Problems presenting modal view controller over UISplitViewController

I have a requirement to present a modal ViewController over a UISplitViewController (i.e. obscuring both the master and detail views, when in landscape).
My code is based on Apple's sample code for Multiple Detail Views, and I've added the presentModalViewcontroller to didFinishLaunching.
To present the modal view, I've used this,
[self.window.rootViewController presentModalViewController:entryView animated:NO];
and this,
[[self.splitViewController.viewControllers objectAtIndex:0] presentModalViewController:entryView animated:NO];
...and both behave in the same way (explained below).
The modal view is presented as I intend, i.e. the view pops up and covers the UISplitView as required. All good so far.
However, as a consequence of presenting the modal view, iOS calls willHideViewController for the obscured UISplitViewController master view. I guess that's reasonable, as the master view is being hidden.
The real problem occurs when the modal view is dismissed, because willShowViewController is NOT called to undo the changes made in willHideViewController (i.e. remove the popover button added to the detail view when the master view was hidden).
This unwanted popover button then sits there, on my Detail view navbar, generally causing a nuisance.
Any thoughts on how to get willShowViewController to be called when the modal view is dismissed, or to otherwise fix this issue would be appreciated.

Resources