![](/img/trans.png)
[英]How to dismiss PopViewController for another ViewController
[英]How to dismiss a viewController from another location
我有一個文件,我在其中定義 controller 的外觀和定義約束和其他內容,在這里我還在下面的按鈕之一上聲明了 addtarget
nextButton.addTarget(self, action: #selector(nextButtonTapped), for: .touchUpInside)
並定義方法,現在一切正常,但在 controller 頁面上,關閉 modalView 的代碼沒有響應,一些從視圖文件調用的關閉代碼的任何變體在 controller 上不起作用,其他任何東西都有效但不關閉
@objc func nextButtonTapped()
{
let index = childController.currentIndex
print(index)
switch index {
case 0...1:
childController.forwardPage()
case 2:
// dismiss(animated: true, completion: nil)
//diss.getDisMiss()
self.presentingViewController?.dismiss(animated: true, completion: nil)
default:
break
}
updateUI()
}
你可以嘗試的是。
self.view.window?.rootViewController?.dismiss(animated: true, completion: nil)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.