2017-09-15 115 views

回答

0

嘗試提出新的的ViewController,與helper方法

extension UIApplication { 
    class func topViewController(base: UIViewController? = (UIApplication.sharedApplication().delegate as! AppDelegate).window?.rootViewController) -> UIViewController? { 
    if let nav = base as? UINavigationController { 
     return topViewController(base: nav.visibleViewController) 
    } 
    if let tab = base as? UITabBarController { 
     if let selected = tab.selectedViewController { 
     return topViewController(base: selected) 
     } 
    } 
    if let presented = base?.presentedViewController { 
     return topViewController(base: presented) 
    } 
    return base 
    } 
} 

呼叫上述輔助方法,從您的視圖控制器像

UIApplication.topViewController().present(vc2, animated: true, completion: nil) 
+0

謝謝!找到頂部視圖控制器並用它來呈現另一個。我知道這種方式,但這不是我想要的。 – iSakuragi

相關問題