UINavigationController doesn't display last stack state when using setViewControllers

Originator:gulan.filip
Number:rdar://48067497 Date Originated:2019-14-02
Status:open Resolved:
Product:iOS SDK Product Version:12.1
Classification: Reproducible:always
 
Area:
UIKit

Summary:

When an empty array of view controllers is set on a UINavigationController, and shortly after an array with some view controller is set, UINavigationController won't display latest change - it will stay empty until you rotate the screen. This is reproducible always when `animated` flag is set to true on `setViewControllers([], animated: true)` method call.

Steps to Reproduce:

Create an empty UINavigationController, set empty view controller array using `setViewControllers([], animated: true)` and then call again `setViewController`, but with some view controller in array: `nav.setViewControllers([vc], animated: true)`.

This can be easily reproducible using this snippet inside `didFinishLaunchingWithOptions` method in AppDelegate:

```
let nav = UINavigationController()
window?.rootViewController = nav
/// Somwhere inside the app
nav.setViewControllers([], animated: true)

let vc = UIViewController()
vc.view.backgroundColor = .red
nav.setViewControllers([vc], animated: true)
/// If you rotate the device - the red view controller will show up

return true
```

Expected Results:

The view controller with red background should be visible.

Actual Results:

There is a black screen without the red view controller in the hierarchy.

Version/Build:

Version 10.1 (10B61)

Configuration:

Device iPhone X 12.1.4, iOS Simulator iPhone SE 12.1

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!