Presentation icon indicating copy to clipboard operation
Presentation copied to clipboard

Delayed presentation of UISplitViewController's content breaks on iPhone with the iOS 13 beta sdk

Open nataliq opened this issue 5 years ago • 6 comments

Expected Behavior

Running the Messages example app on iPhone running iOS 13 should show the list of messages.

Current Behavior

An empty grey screen is shown.

Steps to Reproduce

  1. Build and run the Messages example app with Xcode 11 on an iPhone simulator.

Context

  • Operating Version: iOS 13 beta 1
  • Swift version: 5.1

In the main present method of UIViewController we delay the presentation if the view controller is not loaded yet. It seems like setting the viewControllers of a UISplitViewController or a UINavigationController after it was presented in automatic mode on iPhone (showing only one of the screens), doesn't add the view controllers to the screen even though they are assigned to the property. This can be reproduced by replacing this line of code of the example app:

bag += split.present(viewController, options: [ .defaults, .showInMaster ])

with

let nc = customNavigationController([ .defaults, .showInMaster ])
nc.viewControllers = [viewController]

DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
    split.viewControllers = [nc]
}

Removing the asyncAfter call results in a correct behaviour.

Failure Logs

No logs.

nataliq avatar Jun 09 '19 21:06 nataliq

Dirty fix for the time being:

Add self is UISplitViewController || to the guard statement in UIViewController+Presentation.

nataliq avatar Jun 09 '19 21:06 nataliq

Just to make sure that I understood it correctly.

// 1
bag += split.present(viewController, options: [ .defaults, .showInMaster ])

and

// 2
let nc = customNavigationController([ .defaults, .showInMaster ])
nc.viewControllers = [viewController]

DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
    split.viewControllers = [nc]
}

does not work as expected. But

// 3
let nc = customNavigationController([ .defaults, .showInMaster ])
nc.viewControllers = [viewController]

split.viewControllers = [nc]

has the correct expected behavior?

niil-ohlin avatar Jun 13 '19 12:06 niil-ohlin

Yes, exactly. See this: https://gist.github.com/nataliq/deef2efbd9ddab5e2b3bbf53dff9c0c0 I wanna file a radar but every time I go to the new feedback assistant, it's not working.

nataliq avatar Jun 13 '19 14:06 nataliq

I reported the issue through feedback assistant. Doesn't seem to be addressed in the latest betas too.

nataliq avatar Jul 17 '19 16:07 nataliq

Temporary fix implemented in 1.7.0 (https://github.com/iZettle/Presentation/pull/43)

nataliq avatar Jul 26 '19 09:07 nataliq

Since it was discovered that this also affects UINavigationController, the dirty fix has been expanded to:

shouldPresentImmediately = root is UISplitViewController || vc is UISplitViewController || (root as? UINavigationController)?.viewControllers.isEmpty == true

CJEkman avatar Jan 12 '21 16:01 CJEkman