我有一個簡單的應用程序,當用戶首次登錄到應用程序時,我想顯示一個PageViewController。一旦他們查看了教程,在下一次加載時,PageViewController不會顯示。IOS介紹PageViewController
但是,我收到以下消息。
2017-01-24 00:20:32.620321 Infinity Toolkit[591:83298] Warning: Attempt to present <Infinity_Toolkit.PageViewController: 0x10e026000> on <Infinity_Toolkit.ViewController: 0x10dd0b030> whose view is not in the window hierarchy!
的UIViewController - 默認控制器
override func viewWillAppear(_ animated: Bool) {
displayWalkthroughs()
}
顯示Workthrough功能
func displayWalkthroughs()
{
// check if walkthroughs have been shown
let userDefaults = UserDefaults.standard
let displayedWalkthrough = userDefaults.bool(forKey: "DisplayedWalkthrough")
// if we haven't shown the walkthroughs, let's show them
if !displayedWalkthrough {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
// instantiate neew PageVC via storyboard
if let pageViewController = storyboard.instantiateViewController(withIdentifier: "PageViewController") as? PageViewController {
self.present(pageViewController, animated: true, completion: nil)
print("tried")
}
}
}
我認爲有足夠的代碼,調查那裏。不過,如果您需要,可以上傳更多內容。
謝謝..這對我有效。 – SteveU