モーダルビューコントローラを閉じてルートビューコントローラに戻ることができません。アニメーションは表示されましたが、現在のビューコントローラーが引き続き表示されます。モーダルビューコントローラを閉じることができません
私はストーリーボードを使わずにアプリケーションを開発しています。私は現在のモーダルビューコントローラーを却下し、ルートビューコントローラーに戻したいと思います。
これを行うには適切な方法はありますか?
ルートコントローラーがナビゲーションコントローラーモーダル表示コントローラーがの場合、UIViewControllerです。それは働かない根本的な原因ですか?
モーダルビューコントローラ(PlayerViewController)
func handleBack() {
self.view.window?.rootViewController?.dismiss(animated: true, completion: nil)
}
にHomeControllerでFeedCell.swift(FeedCell.swift)
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let playerViewController = PlayerViewController()
playerViewController.modalPresentationStyle = .overCurrentContext
self.window?.rootViewController?.present(playerViewController, animated: true, completion: nil)
}
AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let layout = UICollectionViewFlowLayout()
window?.rootViewController = UINavigationController(rootViewController: HomeController(collectionViewLayout: layout))
UINavigationBar.appearance().barTintColor = UIColor.rgb(red: 230, green: 32, blue: 31)
// get rid of black bar underneath navbar
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(),for: .default)
application.statusBarStyle = .lightContent
let statusBarBackgroundView = UIView()
statusBarBackgroundView.backgroundColor = UIColor.rgb(red: 194, green: 31, blue: 31)
window?.addSubview(statusBarBackgroundView)
window?.addConstraintsWithFormat(format: "H:|[v0]|", views: statusBarBackgroundView)
window?.addConstraintsWithFormat(format: "V:|[v0(20)]", views: statusBarBackgroundView)
return true
}
示したでした「タップ」しかし、あなたはモーダルとして発表された現在のビューコントローラを却下する場合は、ビューコントローラを提示された1つを呼び出し、提示ビューを却下することを教えてください
ポストコードは、Tj3n @ – Tj3n
が – aznelite89
ポストコードは、モーダルビューコントローラ(PlayerViewController)コードの ' – Vinodh