gpt4 book ai didi

ios - 无法在 TopViewController XCode 8.1、iphone6s/6s+/7/7+ 上点击显示的 ViewController

转载 作者:行者123 更新时间:2023-11-28 08:23:26 25 4
gpt4 key购买 nike

我想在顶级应用程序上显示一个 ViewController,所以我使用下面的代码

let nextStoryBoard = UIStoryboard(name: "Menu", bundle: nil)
let menu = nextStoryBoard.instantiateViewControllerWithIdentifier("MenuView") as! MenuPanelViewController

UIApplication.sharedApplication().keyWindow?.rootViewController!.getTopViewController().modalPresentationStyle = .FullScreen

UIApplication.sharedApplication().keyWindow?.rootViewController!.getTopViewController().presentViewController(menu, animated: false, completion: nil)

当我使用 xCode 7 时一切正常,当我将 xCode 更新到 8.1 时,在 iPhone 6s/6s+/7/7+ 上我无法使用 tapRecognizer。

我认为我的问题与上述设备上的 3D Touch 有关。

最佳答案

请检查您的 getTopViewontroller() 是否正确返回。

这是我用来查找显示最多的 View Controller 的方法。

extension UIApplication {
class func topViewController() -> UIViewController {
return UIApplication.topViewController(base: nil)
}
class func topViewController(base: UIViewController?) -> UIViewController {
var baseView = base
if baseView == nil {
baseView = (UIApplication.shared.delegate as? AppDelegate)?.window?.rootViewController
}
if let vc = baseView?.presentedViewController {
return UIApplication.topViewController(base: vc)
} else {
return baseView!
}
}
}

关于ios - 无法在 TopViewController XCode 8.1、iphone6s/6s+/7/7+ 上点击显示的 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40714990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com