Navigation buttons get stuck when switching between screens using swipe gesture

Originator:brett
Number:rdar://27376141 Date Originated:
Status:Open Resolved:
Product:UIKit Product Version:9.3.2
Classification: Reproducible:
 
Summary:
When a pushed view controller adds right bar button items to the self.navigationItem outside of the main viewDidLoad thread, if the user has already started a swipe back to the preview view controller, but then doesn't actually go back with the swipe gesture, the bar button items added during this swipe interaction are now "stuck" in the navigation bar, so as the user navigates to other screens, bar button items stack up on top of each other.

Steps to Reproduce:
Sample project attached.

Note that the pushed view controller, AnotherViewController has a 5 second delay in viewDidLoad in setting the self.navigationItem.rightBarButtonItem. This is to simulate something like fetching data from an API and displaying a menu bar button in response to that.

1. Launch the app. Note the main view controller's bar button title.
2. Click on the Navigate button, which pushes another view controller
3. Immediately start a swipe back to the previous screen, but wait for 5 seconds holding the gesture (allowing the bar button item to be added).
4. Don't complete the swipe back gesture so that the pushed view controller is still the one that's the active view.
5. Now tap the back button.


Expected Results:
Main view controller's bar button item is the only present bar button item


Actual Results:
Both view controllers' bar button items are stacked on top of each other (see screenshot)


Version:
9.3.2 (13F69)

Notes:


Configuration:
iPhone 6S

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!