I have a parent view controller and a child view controller. I have a button that can show that child view controller. The button does these actions: self.performSegue(withIdentifier: "showComments", sender: self). I also have prepared the segue and set segue.destination.presentationController?.delegate = self. I have put UIAdaptivePresentationControllerDelegate into my view controller and tried putting this function:
public func presentationControllerDidDismiss(
_ presentationController: UIPresentationController)
{
print("dismissed")
}
When I try to drag down the form sheet it doesn't print anything telling me that something is wrong here. Is there a reason to why this is happening?
Edit: Here is my view controller:
import UIKit
class ViewController: UIViewController, UIAdaptivePresentationControllerDelegate {
func presentationControllerWillDismiss(_: UIPresentationController) {
print("yep2")
viewWillAppear(true)
}
@IBOutlet weak var commentImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let vc = CommentingViewController()
vc.presentationController?.delegate = self
let tappp = UITapGestureRecognizer(target: self, action:#selector(ChannelVideoViewController.tapppFunction))
commentImage.addGestureRecognizer(tappp)
// Do any additional setup after loading the view.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
if segue.destination is CommentingViewController {
if segue.identifier == "showComments" {
segue.destination.presentationController?.delegate = self
}
}
}
var isDismissed: Bool = true
@objc func tapppFunction(sender:UITapGestureRecognizer) {
isDismissed = true
self.performSegue(withIdentifier: "showComments", sender: self)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(true)
isDismissed = true
print("View Disappeared")
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
isDismissed = false
print("view appeared")
}
}
Edit 2: I'm not sure if this helps but I also have my child view controller in another storyboard.