Presenting a rotation-forced UIViewController affects the collection view's offset

Originator:RadwanAzzouz
Number:rdar://7496095 Date Originated:12/16/19
Status:Open Resolved:
Product:iOS SDK Product Version:iOS
Classification:Incorrect/Unexpected Behavio Reproducible:Yes
 
Basic Information
Please provide a descriptive title for your feedback:
Presenting a rotation-forced UIViewController affects the collection view's offset
Which area are you seeing an issue with?
UIKit
What type of feedback are you reporting?
Incorrect/Unexpected Behavior
Description
Please describe the issue and what steps we can take to reproduce it:
Presenting a rotation-forced UIViewController affects the collection view's offset.

How to Reproduce:

- Open the attached and modified version the ImageFeed sample project. The original sample project can be found here: https://developer.apple.com/documentation/uikit/uicollectionview/customizing_collection_view_layouts
- Launch the app on an iPhone simulator. This also happens on iPad devices.
- Scroll down a bit to any specific offset. 
- Please observe the top most visible image in the collection view.
- Tap on the the "Present" right bar button item to present the rotation-forced UIViewController.
- Tap on the big red button in the center of the rotation-forced UIViewController to dismiss it.

Expected:

The collection view's offset should remain unchanged after dismissing the rotation-forced UIViewController.

Actual:

The collection view's offset changed after dismissing the rotation-forced UIViewController.

Additional information:

If we comment out the code which forces the rotation in the UIViewController, the offset is unchanged, as expected.

```swift
    // Comment out these two methods and notice that the issue is gone.
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        return .landscapeLeft
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .landscape
    }
```

Comments

Correction: Please note that it only happens on iPhone devices and not on iPad devices.


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!