PanModal
PanModal copied to clipboard
Presenting view controller no longer gets safe area updates once a PanModal has been presented on it
Description
Presenting a pan modal on a view controller will cause iOS to stop updating the safe area insets on the presenting controller while the pan modal is presented.
The root reason for this problem is because PanModal calls appearance transition methods (beginAppearanceTransition
and endAppearanceTransition
) on the presenting controller which are supposed to be called on child controllers.
You can further see that presenting a view controller using overFullScreen
, overCurrentContext
or simply presenting using iOS 13+ style sheets do not call appearance transition methods on the presenting controller since it still exists in the view hierarchy and thus are not actually "disappearing" on presentation and "appearing" on dismissal.
I think that PanModal reflects an overFullScreen
modal presentation style, therefore should act the same and not call appearance transition methods
What type of issue is this? (place an x
in one of the [ ]
)
- [x] bug
- [ ] enhancement (feature request)
- [ ] question
- [ ] documentation related
- [ ] testing related
- [ ] discussion
Requirements (place an x
in each of the [ ]
)
- [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
PanModal version: 1.27
iOS version: 14.4
Note: This is only reproducible where the trait collection does not change since PanModal does not support transitioning between regular & compact width.
Steps to reproduce:
- Constrain something on presenting view controller to safe area
- Present PanModal
- Rotate to different orientation
Expected result:
Safe area of presenting controller should update and constrained views update along with that
Actual result:
Safe area does not update.
Attachments:
Consider this red rectangle constrained to the safeAreaLayoutGuide
of the presenting VC
Default Portrait | Default Landscape |
---|---|
![]() |
![]() |
And see what happens when you present a pan modal then rotate it:
Rotated Portrait to Landscape | Rotated Landscape to Portrait |
---|---|
![]() |
![]() |
Edit: Updated images to use black bg to make it more obvious on GitHub's light theme
This can be reproduced with this simple code:
import UIKit
import PanModal
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let exampleView = UIView()
exampleView.backgroundColor = .red
exampleView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(exampleView)
exampleView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
exampleView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
exampleView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
exampleView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
let tap = UITapGestureRecognizer(target: self, action: #selector(tappedView))
exampleView.addGestureRecognizer(tap)
}
@objc private func tappedView() {
presentPanModal(PanViewController())
}
}
class PanViewController: UIViewController, PanModalPresentable {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
}
var panScrollable: UIScrollView? {
nil
}
var shortFormHeight: PanModalHeight {
.contentHeight(100)
}
var longFormHeight: PanModalHeight {
.maxHeight
}
}