저는 신속한 답변을 얻지 못했으며 경고보기 강의에서 일부 자습서를 따랐습니다. 나는 alert 버튼이 클릭 될 때마다 또 다른 viewcontroller를 호출하는 것과 같은 함수를 추가하고 싶다. 그러나 나는 그 방법을 모른다.alertcontroller에서 버튼에 기능 추가
let cancelAction = UIAlertAction(title: cancelButtonTitle, style: .Cancel){
action in NSLog("No!!!!")
let View2 = self.storyboard?.instantiateViewControllerWithIdentifier("View2") as TwoViewController
self.navigationController?.pushViewController(View2, animated: true)
}
을 또한 기존의 뷰 컨트롤러를 선택하고 드롭 다운 메뉴에서> 삽입에> 네비게이션 컨트롤러편집을 선택 : 그래서 pls는 저
func showAlertController(){
var title : String = "hi!"
var message : String = NSLocalizedString("Are you feeling well? ", comment:"")
let cancelButtonTitle = NSLocalizedString("No", comment:"")
let otherButtonTitle = NSLocalizedString("Yes", comment:"")
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: cancelButtonTitle, style: .Cancel){
action in NSLog("No!!!!")
}
let otherAction = UIAlertAction(title: otherButtonTitle, style: .Default){
action in NSLog("welcome!!! hello back")
}
alertController.addAction(cancelAction)
alertController.addAction(otherAction)
presentViewController(alertController, animated: true, completion: nil)
}
알림을 표시하는 [UIAlertViewController] (http://www.appcoda.com/uialertcontroller-swift-closures-enum/)를 보시라. –