قالب وردپرس درنا توس
Home / IOS Development / IOS – Why is UIPresentationController altitude changed when there is another controller?

IOS – Why is UIPresentationController altitude changed when there is another controller?



I use UIPresentationController to view the bottom tip. Sometimes the presentation controller may present another controller. And when the presented controller is rejected, the presentation control height was changed. So why did it change and how can I solve this problem. The code likes below:

  class ViewController: UIViewController {

la presentVC = UIViewController ()
override func viewDidLoad () {
super.viewDidLoad ()
DispatchQueue.main.asyncAfter (deadline: .now () + 1) {[weak self] i
guard let `self` = even other {return}
self.presentBottom (self.presentVC)
}

DispatchQueue.main.asyncAfter (deadline: .now () + 2) {[weak self] i
guard let `self` = even other {return}
la VC = UIViewController ()
VC.view.backgroundColor = .red
self.presentVC.present (VC, animated: true, completion: {

DispatchQueue.main.asyncAfter (deadline: .now () + 1
) { VC.dismiss (animated: true, completion: null) } }) } } }
  Public class PresentBottom: UIPresentationController {

public override was frameOfPresentedViewInContainerView: CGRect {
la bottomViewHeight: CGFloat = 200.0
la screenBounds = UIScreen.main.bounds
return CGRect (x: 0, y: screenBounds.height - bottomViewHeight, width: screenBounds.width, height: bottomViewHeight)
}

}
  extension UIViewController: UIViewControllerTransitionDelegate {

public func presentBottom (_ vc: UIViewController) {
vc.view.backgroundColor = .purple
vc.modalPresentationStyle = .custom
vc.transitioningDelegate = self
self.present (vc, animated: true, completion: null)
}

public func presentationController (forPresented presented: UIViewController, present: UIViewController?, source: UIViewController) -> UIPresentationController? {
la vc = PresentBottom (presentedViewController: presented, present: present)
return vc
}
}

My tags as below:
“/>

Enter image description here “/>

The height of current view control is in the picture below:

  Enter image description here

What confused me is that the current view control height has changed:

  description here


Source link