gpt4 book ai didi

ios - swift - 警告 : attempt to present on whose view is not in the window hierarchy

转载 作者:搜寻专家 更新时间:2023-11-01 05:54:18 24 4
gpt4 key购买 nike

当我在我的 SecondViewController 中点击后退按钮时,我遇到了这个问题。

2014-12-24 12:08:58.838 UPASS[5158:71438] Warning: Attempt to present <APPNAME.ThirdViewController: 0x7ae6bcc0> on <APPNAME.SecondViewController: 0x7af72060> whose view is not in the window hierarchy!

代码

import UIKit

class SecondViewController: UIViewController {

@IBAction func btnSubmit(sender: AnyObject) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

let thirdViewController = storyBoard.instantiateViewControllerWithIdentifier("successView") as ThirdViewController
self.presentViewController(thirdViewController, animated:true, completion:nil)
}

@IBAction func btnBack(sender: AnyObject) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

let firstViewController = storyBoard.instantiateViewControllerWithIdentifier("methodView") as FirstViewController
self.presentViewController(firstViewController, animated:true, completion:nil)

}

override func viewDidLoad() {
super.viewDidLoad()

self.view.backgroundColor = UIColor(patternImage: UIImage(named: "bgCreateUser.jpg")!)
// Do any additional setup after loading the view.
}


}

最佳答案

btnBack 是否应该返回到较早的 View Controller ?如果是这样,不要呈现一个新的实例,而是使用以下方法返回到前一个实例:

dismissViewControllerAnimated(真,完成:无)

关于ios - swift - 警告 : attempt to present on whose view is not in the window hierarchy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27631399/

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