I have a UICollectionView that the user can clicks and it shows a popover attached to the cell clicked. In iOS 12, the popover stayed in the same origin (x,y or cell) if the reload data was called or not, but in iOS 13, the popover moves between the cells when the reload data of the collection view is called.
Follow a video of the behavior in iOS 13: https://vimeo.com/385021234
The presentation is done using the following code:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let cell = collectionView.cellForItem(at: indexPath) else {
return
}
presentPopover(from: self, cell: cell)
}
func presentPopover(from view: UIViewController, cell: UIView) {
let popoverView = PopoverViewController(nibName: "PopoverViewController", bundle: nil)
let popover: UIPopoverPresentationController = popoverView.popoverPresentationController!
popover.sourceRect = cell.bounds
popover.sourceView = cell
view.present(popoverView, animated: true, completion: nil)
}
And the PopoverViewController is using the modalPresentationStyle = .popover
Anyone had this issue before in iOS 13? Our application was working fine in iOS 11 and 12.
I have an example of this behavior in the following git repository: https://github.com/diegodossantos95/UICollectionViewPopoverBug
Steps to reproduce in the repository:
Click on a collection cell
Popover opens
Wait for the reload data
Thanks,
Diego.