gpt4 book ai didi

ios - MyViewController 是否在窗口层次结构中?

转载 作者:搜寻专家 更新时间:2023-10-31 22:00:28 24 4
gpt4 key购买 nike

有没有办法检查 MyViewController 是否在窗口层次结构中?我想知道我是否可以从中呈现一个 UIAlertController :

var alert = UIAlertController(title: "Hello", message: "Just for fun", preferredStyle: UIAlertControllerStyle.Alert)
MyViewController.presentViewController(alert, animated: true, completion: nil)

最佳答案

View Controller 的 view 如果在层次结构中,将设置其 window 属性

if MyViewController.view.window != nil {
// In the window hierarchy
}

关于ios - MyViewController 是否在窗口层次结构中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30941424/

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