ナビゲーションバーのメニューボタンを押したときに表示されるスライドインメニューがあります。それを却下するには、背景またはメニュー自体をタップするか、どちらかを実行します。このビューの中にはいくつかの項目があり、そのうちの1つはユーザープロファイルボタンです。このボタンを押すと、メニューを閉じてからユーザープロファイルビューコントローラーをすぐに開くことができます。だから私はhandleDismiss()をと呼んで開き、開く必要のあるビューを設定します。スウィフト - スライドインメニュー内からUIViewControllerを開きます。
しかし、ビューはウィンドウ階層内にないことを続けています。私は問題が何であるかを知っている(スタックを見る)が、どうにかして正しく動作するようにはできない。どのようにこの問題に取り組むべきですか?
RootViewController - >にHomeController(タブバーインデックス0) - >スライドのメニュー - コントローラ
profileCell.profileButton.addTarget(self, action: #selector(handleUserProfile(sender:)), for: .touchUpInside)
機能
func handleDismiss() {
UIView.animate(withDuration: 0.5) {
self.blackView.alpha = 0
if let window = UIApplication.shared.keyWindow {
self.collectionView.frame = CGRect(x: 0, y: window.frame.height, width: self.collectionView.frame.width, height: self.collectionView.frame.height)
}
}
}
func handleUserProfile(sender: UIButton) {
handleDismiss()
let userProfileController = UserProfileController()
openProfileController(userProfileController)
}
func openProfileController(_ controller: UIViewController) {
present(controller, animated: false, completion: nil)
}
を開くため> UserProfileController
ボタン