UIAlert에 대한 약간의 도움이 필요합니다. "UIAlertController can only have one action with a style of UIAlertActionStyleCancel"
오류가 발생합니다. 나는 그것이 기능의 외부에서이 경고를 시작하고 있기 때문에 그것을 알고있다. 그러나 그것을 고치는 방법을 확신 할 수 없다. 조건부 인 경우 blah < 80 {
인 경우 알림에 액세스하려면 어떻게해야합니까?프로그래밍 방식으로 경고를 닫습니다.
let alertView = UIAlertController(title: "Blah", message: "", preferredStyle: UIAlertControllerStyle.Alert)
@IBAction func blahButtonPressed(sender: AnyObject) {
alertView.addAction(UIAlertAction(title: "Do Something", style: .Default, handler: { (action: UIAlertAction!) in
// I have code here
}))
alertView.addAction(UIAlertAction(title: "Do Something 2", style: .Default, handler: { (action: UIAlertAction!) in
// I have code here
}))
alertView.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
// I have code here
}))
presentViewController(alertView, animated: true, completion: nil)
}
나중에 코드에서 나는 사람이 건너 오면 나는 그것을 해결하는 방법 다음은 블루투스를 통해 값을 얻을 값이 80
if blah < 80 {
alertView.dismissViewControllerAnimated(true, completion: nil)
}
(이상 "UIAlertActionStyleCancel"의 스타일로 하나
UIAlertAction
초래)은 "blahButton은"누를 때마다 한 시간이 추가되지 않습니다 'blahButtonPressed'가 두 번 이상 실행될 가능성이 있습니까? '취소'를 너무 많이 추가하는 것처럼 오류 메시지가 나타납니다. –아니요. 버튼 일뿐입니다. 나는 한 번만 누르면 다른 곳으로 전화하지 않는다. – KotaBear233