作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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
则使用 UINavigationController
的 visibleViewController
属性
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/
我是一名优秀的程序员,十分优秀!