【发布时间】:2017-05-08 12:20:07
【问题描述】:
我编写了这段代码,以便 viewcontroller 从 loginscreenviewcontroller 更改为 otpviewcontroller。
function createAlert() {
let alertController = UIAlertController(title: nil, message: "Please wait\n\n", preferredStyle: .alert)
let spinnerIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
spinnerIndicator.center = CGPoint(x: 135.0, y: 65.5)
spinnerIndicator.color = UIColor.black
spinnerIndicator.startAnimating()
self.present(alertController, animated: true, completion: nil)
Alamofire.request(".....").responseData { response in
switch response.result {
case .success:
self.dismiss(animated: true, completion: nil)
self.performSegue(withIdentifier: "OTPSegue", sender: self)
}
}
}
但它给了我一个错误
Attempt to present <Junkart.OTPViewController: 0x79769c80> on <UIAlertController: 0x79b5fe00> whose view is not in the window hierarchy!
警报控制器确实关闭了,但视图控制器没有变化。
请帮忙。
UPADTE 2 行。因此,我可以更改为另一个 viewController,但警报视图会在新视图控制器动画并占据整个屏幕之前到达顶部。
【问题讨论】:
-
嗨,这个答案可以帮助你stackoverflow.com/questions/28451295/…
-
createAlert 是在 ViewDidLoad 中调用的吗?