gpt4 book ai didi

ios - 如何从 AppDelegate 显示表单?

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

AppDelegate 检查用户是否登录,如果没有,则从用户在应用程序中的任何位置显示 formSheet View

我该怎么做?

最佳答案

您可以在 appdelegate 类中使用像 rootViewController 这样的窗口属性

试试这个:-

if let rootVC = self.window?.rootViewController as? YourViewController {
//Add the code here to present signupviewcontroller as form sheet
}

如果你的 rootVC 是 UINavigationController 则使用 UINavigationControllervisibleViewController 属性

if let nsvigationVC = self.window?.rootViewController as? UINavigationController  {
if yourVC = nsvigationVC.visibleViewController {
//Add the code here to present signupviewcontroller as form sheet
let sb = UIStoryboard(name: “Main”, bundle: nil) //get signupviewcontroller from storyboard
let signupVC = sb.instantiateViewControllerWithIdentifier("signupviewcontroller") as! signupviewcontroller
signupVC.modalPresentationStyle = UIModalPresentationStyle.FormSheet
signupVC.preferredContentSize = CGSize(width: 365, height: 500) // set content size as per your requirement
yourVC.presentViewController(signupVC, animated: true, completion: nil)
}

}

关于ios - 如何从 AppDelegate 显示表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43600984/

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