I'm using UIKit in Swift.
I have a button that opens a sheet:
@objc func myButtonTapped(_ sender: UIButton) {
if let myTitle = sender.title(for: .normal) {
let sheet = self.storyboard?.instantiateViewController(withIdentifier: "myConfigView") as! myConfigViewController
sheet.title = myTitle
self.present(sheet, animated: true)
}
}
There is a label on the sheet that, if I press it, I want a new view to open. But it's not working. The sheet code:
class myConfigViewController: BaseViewController, UISheetPresentationControllerDelegate {
override var sheetPresentationController: UISheetPresentationController{
presentationController as! UISheetPresentationController
}
@IBOutlet weak var TitleUILabel: UILabel!
@IBOutlet weak var openUILabel: UILabel!
var title:String = ""
override func viewDidLoad() {
super.viewDidLoad()
sheetPresentationController.delegate = self
sheetPresentationController.selectedDetentIdentifier = .medium
sheetPresentationController.prefersGrabberVisible = false
sheetPresentationController.detents = [.medium()]
TitleUILabel.text = title
let tapGesture1 = UITapGestureRecognizer(target: self, action: #selector(openNewViewLabelTapped))
openUILabel.isUserInteractionEnabled = true
openUILabel.addGestureRecognizer(tapGesture1)
}
@objc func openNewViewLabelTapped() {
print("Open the new View")
self.dismiss(animated: false){
let destViewController = self.storyboard!.instantiateViewController(withIdentifier: "isNewView") as! isNewViewController
self.navigationController?.pushViewController(destViewController, animated: true)
}
}
}
It doesn't show any errors. Do nothing.
What is the solution?
THANKS!