UICollectionView performBatchUpdates does not work as documented
| Originator: | neilmggall | ||
| Number: | rdar://13924314 | Date Originated: | 2013-05-17 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 6.1 |
| Classification: | Serious Bug | Reproducible: | Always |
The documentation for UICollectionView performBatchUpdates:completion: states: "When you group operations to insert, delete, reload, or move sections inside a single batch job, all operations are performed based on the current indexes of the collection view. This is unlike modifying a mutable array where the insertion or deletion of items affects the indexes of successive operations. Therefore, you do not have to remember which items or sections were inserted, deleted, or moved and adjust the indexes of all other operations accordingly." This does not appear to be the case. In the attached example, there are 8 items in the collection view, and buttons to move the first three items in the collection to the end. - Before change: cells indexed 0..7 exist - Following the above documentation, on change insert cells 8,9 and 10 (to insert at the end) and delete cells 0, 1 and 2 (to remove from the beginning). This causes a crash. - If instead we insert cells 5, 6 and 7 then delete cells 0, 1 and 2, the collection view is correctly updated. If the documentation is to be believed, the insertion operation should be based on the current indexes. To ensure the new items appear at the end, their indices must be higher than all the current indices. According to the documentation, inserting items at indices 5,6 and 7 would add these items between current indices 5 and 6. Steps to Reproduce: Execute the attached example project. The "who needs docs?" button moves the top three cells in the collection view to the end, but achieves this by not following the documentation quoted above. The "by the book" follows the documentation above, but causes an assertion failure in the UICollectionView. Expected Results: As per the documentation, the "by the book" button should yield the correct result and the "who needs docs?" button should not. Actual Results: The "by the book" button causes an assertion failure, and the "who needs docs?" button works correctly. Regression: No. Notes: Example project at http://d.pr/f/qkWD
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!