Wrong items distribution on UIToolbar

Originator:enrique0703
Number:rdar://6468254638 Date Originated:20/03/2018
Status:Open Resolved:NO
Product:UIKit Product Version:
Classification:bug Reproducible:YES
 
When adding the same instance of UIBarButtonItem initialized with an image several times to a UIToolbar along with some flexibleSpace between them, it doesn't seem to distribute the items properly. However if you add different instances of UIBarButtonItem or the same instance but initialized with a title, it works perfectly. 
The results for both iOS 8.0 and iOS9/iOS10/iOS11 are different since on iOS9 and newer the UIToolbar uses a UIStackView internally to distribute the items.

It is quiet unlikely that a developer want to add the same instance of UIBarButtonItem to a UIToolbar, but It could be the case. In case that it won't be fixed, It would be necessary to update the documentation to clarify it.

Steps to Reproduce:
- Create UIToolbar.
- Create UIBarButtonItem and name it as "item" for instance, with the init(image:style:target:action) initializer 
- Create UIBarButtonItem (flexibleSpace system type) and name it as "flexibleSpace" for instance. 
- Set the items to the UIToolbar like so: setItems([item, flexibleSpace, item, flexibleSpace, item], animated: true)

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!