在 Swift 中,可以通過檢查當(dāng)前視圖控制器的 presentingViewController
屬性來判斷是通過 push 過來的頁面還是 present 過來的頁面。文章來源:http://www.zghlxwxcb.cn/news/detail-607928.html
下面是一個示例代碼,展示如何判斷是通過 push 還是 present 過來的頁面:文章來源地址http://www.zghlxwxcb.cn/news/detail-607928.html
if let presentingViewController = self.presentingViewController {
// 通過 present 過來的頁面
self.dismiss(animated: true, completion: nil)
} else if let navigationController = self.navigationController {
// 通過 push 過來的頁面
navigationController.popViewController(animated: true)
}
到了這里,關(guān)于Swift 中如何判斷是push 過來的頁面 還是present過來的 頁面的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!