0
所以我有一個根視圖控制器,當用戶按下另一個視圖控制器時,會有一個按鈕。這第二個控制器有一個解除選項,它只是回到根視圖控制器和一個按鈕,當用戶觸摸它時會取消當前的視圖控制器,以便它返回到根視圖控制器一秒鐘,並呈現另一個視圖控制器。去我使用的第一個控制器:目前一個控制器忽略它,並在Swift中呈現不同的一個
let vc = FirstController()
self.present(vc, animated: true, completion: nil)
而當在另一個視圖控制器我選擇按鈕,只有解僱我這樣做。
self.dismiss(animated: true, completion: nil)
因此,對於需要解僱並提出另外一個我曾嘗試以下第二個控制器:
self.dismiss(animated: true, completion: {
let vc = SecondController()
self.present(vc, animated: true, completion: nil)
})
但我得到一個錯誤:
Warning: Attempt to present <UINavigationController: 0xa40c790> on <IIViewDeckController: 0xa843000> whose view is not in the window hierarchy!