0
내 컬렉션보기의 각 셀에는 버튼과 텍스트 필드가 있습니다.보기에서 UIAlertController를 표시하는 방법은 무엇입니까?
버튼을 누르면 텍스트 필드가 비어 있으면 경고를 표시하려고합니다. 내 사용자 지정 모음보기 세포에서
나는이 :
func displayAlert(title: String, error: String) {
var alert = UIAlertController(title: title, message: error, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { action in
alert.dismissViewControllerAnimated(true, completion: nil)
}))
self.presentViewController(alert, animated: true, completion: nil)
}
func redeemButtonPressed(sender: UIButton!) {
if enterCodeTextField.text == "" {
displayAlert("Something went wrong", error: "Please enter a valid code")
}