iOS 13 new presentation styles - presenting VC not shrinking down - ios

I am having a problem with the new VC presentation styles in iOS 13. I want to implement the new "stack" presentation.
However I do have an issue where the PRESENTING view controller is not shrinking down as it should causing a really ugly look.
The only solution I found to this problem is setting the background (ie presenting) VC as the new root view controller with
window.rootViewController = self
However this is not recommended by Apple and causes lots of odd bugs like dissapearing status bar or cutting of segue animations.
Can someone please explain to me how to fix this issue or how to properly use the new presentation styles or how to properly set a new root VC.
The intended behaviour:
The buggy behaviour:

Related

My UINavigationBar seems to become out of sync with UINavigationController (see gif below)

When I try to back out of my Navigation stack using either the back button or swiping back from the left side of the screen, the navigation bar changes but does not dismiss the ViewController (or, in the case of swiping, the navbar animation is not interruptible). Please see the gif below.
I'm implementing my NavigationController with storyboard. It's just a UIViewController embedded into a UINavigationController. I've tried detaching the UIViewController and reattaching it to a different NavControl, manually embedding it, removing the TabBar controller that was also embedded originally. All of these have led to the same result.
Edit: Also relevant is how I'm pushing these ViewControllers to the nav stack. To present these VCs, I'm just using navigationController?.pushViewController(vc, animated: true).
present(_: UIViewController,animated: Bool) gives a modal presentation which is not what I'm looking for.
Any ideas as to what would be causing this odd behavior?
I had the following in my rootViewController's viewDidLoad from some earlier experimentation that wasn't being used:
// Setting as delegate might not be necessary right now,
// could become useful in the future?
navigationController?.navigationBar.delegate = self
Evidently it did not become useful in the future. Seems like doing this causes the delegate to become responsible for some of the work navBar usually does for free? Removing it immediately fixed the issue.

Weird UIViewController hidesBottomBarWhenPushed layout bug that only occurs the very first time a view controller is pushed

I'm really at a loss with this one, especially considering it has previously been working fine and I can't find anything in my commits that would have broken it.
I have a UITabBarController as the master view of a UISplitViewController. Each tab in the UITabBarController has its own UINavigationController that manages a stack of child VCs.
The issue is that any child VCs that have hidesBottomBarWhenPushed set to true results in a glitchy transition, but only the very first time any UINavigationController push occurs.
Here is a video of the transition bug
As you can see, it appears as if the safe area is collapsing on transition (and indeed, this does not occur on iPad or any other iPhone that lacks a bottom safeAreaInset. Yet, on the second (and all subsequent) push, it behaves perfectly fine.
The only thing I can think of is that I'm implementing the UISplitViewControllerDelegate methods to ensure Show Detail segues occur as a push rather than a modal when on the iPhone. However, the issue still happens with a regular push (bypassing the delegate methods altogether).
The various view controllers are all the standard base classes with no overridden layout behaviour, and I'm not implementing any custom transitions or transition coordinators.
Any thoughts on what the issue might be would be greatly appreciated.
So I managed to fix it. I was performing a modal segue before the UITabBarController was coming on screen. Apparently that messes up the layout, as I was able to confirm via a minimal replication. Changing the segue presentation type to "over full screen" rather than "default" stops the underlying UITabBarController from being removed from the view hierarchy and fixes the issue.
While that's six hours of my life I'll never get back I hope it helps someone in future.

UINavigationController animation from view controller with prompt

I am implementing an application that uses a UINavigationController. It currently shows 3 views, each a UITableViewController. The first view that is shown only has a title, while the other two have a title and prompt. All segues are created in the storyboard, which is rather straightforward:
The problem: As soon as I animate AWAY from a view that has a prompt, the animation glitches - the title (and sometimes the back button) "fly in" from the bottom, instead of from the right.
Example: https://youtu.be/N-K8piEJ1aY (recording with slow animations turned on)
Here you can see that the animation from first to second view works fine, but from second to third view is glitchy. animating back works.
This issue seems similar to Weird animations when changing NavigationItem prompt . The conclusion in that thread was that this only occurs on iOS 7, I am running on iOS 10.0/10.1, though. The issue occurs both in simulator and on the real device.
Any ideas?
The only solution I found was an absolute hack inspired by an absolute hack inspired by Catalina T. over on this post:
Either in viewWillAppear: on the appearing VC or after calling pushViewController:animated: on the navigation controller (or I'm guessing after calling performSegueWithIdentifier:sender: add the following code:
ObjC
// This is a hack that's because UINavigationBar with prompts is broken
navigationController.navigationBarHidden = YES;
navigationController.navigationBarHidden = NO;
Swift
// This is a hack that's because UINavigationBar with prompts is broken
navigationController.isNavigationBarHidden = true
navigationController.isNavigationBarHidden = false
where navigationController is a reference to the UINavigationController that's doing all the pushing (e.g. viewController.navigationController)
EDIT: It appears now there're other weird animations that occur when popping and repushing a VC, so this answer isn't a true solution. Leaving it up so as to help someone else down a similar rabbit hole.

Second pushed View Controller with UISearchController doesn't receive touches in UINavigationBar

I modified AAPLSearchBarEmbeddedInNavigationBarViewController in Apple's UICatalog sample code so that it pushes another instance of AAPLSearchBarEmbeddedInNavigationBarViewController onto the navigation stack when a cell is selected. In the second view controller the UISearchBar set as the title view of the UINavigationBar (just like the first one) isn't tappable (unlike the first the one). This seems like a bug. How do I fix it? Here is my modified UICatalog code:
https://github.com/stevemoser/UICatalog
Also I tested with with Xcode 6 and 7. It's broken in both.
The solution is to set the first VC self.definesPresentationContext = NO when navigating away from it and making sure to call self.definesPresentationContext=YES in the view did appear so that the visible VC allows defines the presentation context.
Thanks goes to Rory McKinnel who put me on the right track.

presentingViewController is nil when using presentViewController:animated:completion: in iOS 8

Wondering if anyone else has encountered this issue recently...
For one of my view controllers , only on iOS 8, after calling presentViewController:animated:completion:, the presented view controller has self.presentingController as nil. It is fine on iOS7, and also does not happen on another view controller.
The documentation says that it should be set, as long as the presented view controller was presented modally. Given it works in iOS 7, could this be an iOS 8 bug?
I've been able to get around it using a view container containment approach, but it would be good if someone has seen this before and knows the root cause that triggered this behaviour.
thanks
Had a similar issue with iOS 8, where presentingController is nil when checking the value in viewDidLoad.
When viewDidLoad is called, there is no guarantee that the view controller hierarchy is loaded in the navigation tree. Moving the logic to a later stage (for example: viewWillAppear) should resolve that issue as presentingController should be loaded by then.

Resources