내 코드는 잘 작동했지만 이전에 어떤 이유로 오늘은 다른 작업을 수행했습니다. 기본적으로 사용자가 짧은 사용자 이름, 이메일 또는 암호를 사용 중일 경우 알림을 표시하려고합니다. 그렇지 않으면 등록이 완료되었다는 경고를 보내고 다음보기로 이동합니다. 그러나 지금은 제출을 클릭하자 마자 경고를 무시하고 다음보기로 간다. 당신이 볼 수 있듯이, 나는 그것이 단지 전체의 다음보기로 이동합니다 알려주는 핸들에 SEGUE "signUpDone"가UIAlert가 갑자기 작동하지 않습니까?
@IBAction func signUp(_ sender: Any) {
// Validate the text fields
if username!.count < 5 {
let alert = UIAlertController(title: "Invalid", message: "Username must be greater than 5 characters", preferredStyle: UIAlertControllerStyle.alert)
let action = UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
} else if password!.count < 8 {
let alert = UIAlertController(title: "Invalid", message: "Password must be greater than 7 characters", preferredStyle: UIAlertControllerStyle.alert)
let action = UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
} else if email!.count < 8 {
let alert = UIAlertController(title: "Invalid", message: "Email must be greater than 7 characters", preferredStyle: UIAlertControllerStyle.alert)
let action = UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Success", message: "Account has been created, an email will be sent shortly", preferredStyle: UIAlertControllerStyle.alert)
let action = UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: {
action in
self.performSegue(withIdentifier: "signUpDone", sender: self)
})
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
}
: 여기에 코드입니다. 그러나 어떤 이유로 든 모든 if 문을 무시하고 조건이나 성공적인 경고에 대한 경고없이 다음보기로 이동합니다. "경고 : 누구의보기가 윈도우 계층 구조에 있지 않습니까?"라는 콘솔 정보가 나타납니다.
코드를 건드리지 않았지만 이상하게도 오늘 실행하려고 할 때 발생합니다. 무엇이 문제 일 수 있습니까?