有关如何执行此搜索的任何想法。用户注册并通过身份验证后,他们会看到插页式广告。但是,一旦广告完成或被撤消。应该执行到下一个视图控制器的选择。我不确定我的代码中缺少什么:
@IBAction func signUpBtn_TouchUpInside(_ sender: Any) {
view.endEditing(true)
ProgressHUD.show("Waiting...", interaction: false)
if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1) {
AuthService.signUp(username: usernameTextField.text!, email: emailTextField.text!, password: passwordTextField.text!, imageData: imageData, onSuccess: {
ProgressHUD.showSuccess("Success")
if self.interstitial.isReady {
self.interstitial.present(fromRootViewController: self)
} else {
print("Ad wasn't ready")
self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
}
self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
}, onError: { (errorString) in
ProgressHUD.showError(errorString!)
})
} else {
ProgressHUD.showError("Profile Image can't be empty")
}
}
总是非常感谢帮助或反馈
答案 0 :(得分:0)
您应该使ViewController
符合interstitial
delegate
,并在segue
被取消后执行interstitial
extension ViewController: GADInterstitialDelegate {
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
}
}
并如下更新signUpBtn_TouchUpInside
方法,
@IBAction func signUpBtn_TouchUpInside(_ sender: Any) {
view.endEditing(true)
ProgressHUD.show("Waiting...", interaction: false)
if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1) {
AuthService.signUp(username: usernameTextField.text!, email: emailTextField.text!, password: passwordTextField.text!, imageData: imageData, onSuccess: {
self.handleSignupSuccess()
}, onError: { (errorString) in
ProgressHUD.showError(errorString!)
})
} else {
ProgressHUD.showError("Profile Image can't be empty")
}
}
private func handleSignupSuccess() {
ProgressHUD.showSuccess("Success")
if self.interstitial.isReady {
self.interstitial.delegate = self
self.interstitial.present(fromRootViewController: self)
} else {
print("Ad wasn't ready"
self.performSegue(withIdentifier: "signUpToTabbarVC", sender: nil)
}
}