AlertDialog and Response Function
- Developer/Swift
- 2018. 5. 2. 14:58
기본 얼럿 다이얼로그와 버튼 선택 시 액션 처리 코드. 어째 objC랑 좀 다른 구석이 많군요.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | func startAlertDialog () -> Void { // alertDialog let testAlert : UIAlertController = UIAlertController.init(title: "ALERTTITLE", message: "ALERTMESSAGE", preferredStyle: UIAlertControllerStyle.alert); // 얼럿 버튼 및 Resonse 함수 추가 let testAlertButton1 : UIAlertAction = UIAlertAction(title: "ALERT ACTION 1", style: UIAlertActionStyle.default, handler: { action in self.alertButtonResponse(tag: "1") }); let testAlertButton2 : UIAlertAction = UIAlertAction(title: "ALERT ACTION 2", style: UIAlertActionStyle.default, handler: { action in self.alertButtonResponse(tag: "2") }); let testAlertButton3 : UIAlertAction = UIAlertAction(title: "ALERT ACTION 3", style: UIAlertActionStyle.default, handler: { action in self.alertButtonResponse(tag: "3") }); // 다이얼로그에 버튼 추가 testAlert.addAction(testAlertButton1); testAlert.addAction(testAlertButton2); testAlert.addAction(testAlertButton3); // 시작 self.present(testAlert, animated: true, completion: nil); } // alertButton 선택 후 Response func alertButtonResponse (tag : String) { NSLog("===== alertButtonResponse tag : %@", tag); } | cs |
자주 써먹을 수 있어야 잊지 않을텐데..ㅋㅋ
'Developer > Swift' 카테고리의 다른 글
pageControl (0) | 2018.05.04 |
---|---|
NavigationController / NavigationItem (0) | 2018.05.02 |
AlertDialog and Response Function (0) | 2018.05.02 |
pickerview with CustomView (0) | 2018.04.30 |
Extention (0) | 2018.04.20 |
Swift 각종 용어 정리 (지속 업데이트 필요) (0) | 2018.04.20 |
이 글을 공유하기