1
AppDelegate
は、ユーザーがログインしているかどうかをチェックし、ユーザーがログインしていない場合は、ユーザーがアプリケーション内のどこからでもformSheet view
を表示します。AppDelegateからフォームシートを表示するには?
どうすればよいですか?
AppDelegate
は、ユーザーがログインしているかどうかをチェックし、ユーザーがログインしていない場合は、ユーザーがアプリケーション内のどこからでもformSheet view
を表示します。AppDelegateからフォームシートを表示するには?
どうすればよいですか?
あなたはappdelegateクラスにrootViewController
ようなウィンドウプロパティを使用することができます
これを試してください: -
if let rootVC = self.window?.rootViewController as? YourViewController {
//Add the code here to present signupviewcontroller as form sheet
}
あなたrootVCこれは想定していUINavigationController
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)
}
}
の
visibleViewController
プロパティを使用するよりも、UINavigationController
ある場合ルートコントローラは最上位のビューコントローラです。この質問に基づいて、これは常にそうであるとは限りません。 – rmaddy@ rmaddy Answer updated、 –
フォームシートとして 'signupviewcontroller'を提示するコードは何でしょうか? – Berry