UINavigationControllerDelegate method being called twice

Originator:pavel.dusatko
Number:rdar://29912893 Date Originated:06-Jan-2017 06:57 PM
Status:Duplicate/9602023 Resolved:
Product:iOS + SDK Product Version:
Classification: Reproducible:
 
Area:
UIKit

Summary:
The following application architecture:

- UITabBarController (root)
-- UINavigationController (delegate = AppDelegate or any other object)
-- UINavigationController (delegate = AppDelegate or any other object)
-- ...

causes duplicate delegate calls to the following UINavigationControllerDelegate method if the navigation controller in the tab bar controller hasn't been loaded yet and is being selected in the tab bar:

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool)

every consequential selection of the view controller in the tab bar causes correctly just one call.

Steps to Reproduce:
1. Launch provided sample code (Sample.xcodeproj)
2. Toggle console ON
3. Switch to "Second" tab (not loaded yet)
>> logs 2 lines
4. Switch to "Third" tab (not loaded yet)
>> logs 2 lines
5. Switch back to any tab (all are loaded now)
>> logs 1 line

Expected Results:
Each tab selection should only call the UINavigationControllerDelegate method once

Actual Results:
For controllers that are still not loaded the UINavigationControllerDelegate method is being called twice

Version:
iOS 10

Notes:


Configuration:
iPhone 7

Attachments:
'Sample.zip' was successfully uploaded.

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!