IOS(iPhone)

ios swift3 확인(Ok), 취소(Cancel) 다이얼로그 만들기

알통몬_ 2017. 11. 17. 14:24
반응형


공감 및 댓글은 포스팅 하는데

 아주아주 큰 힘이 됩니다!!

포스팅 내용이 찾아주신 분들께 

도움이 되길 바라며

더 깔끔하고 좋은 포스팅을 

만들어 나가겠습니다^^

 


이번 포스팅에서는


제목대로 ios 에서 Ok, Cancel 다이얼로그 만드는 방법입니다.


전에 포스팅했던 다이얼로그만들기에서 심화된 단계입니다.


확인,취소 다이얼로그는 우리가 앱에서 자주 볼 수 있죠.


좀 귀찮은 앱들은 종료할 때 종료할 건지 묻는 다이얼로그가 나오니까요 ㅎㅎ





만드는 방법은 간단합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let alert : UIAlertController = 
                UIAlertController(title: commuteAlertTitle, 
                                  message: commuteAlertMsg,
                                  preferredStyle: .alert)
        let okAction : UIAlertAction = UIAlertAction(title: "확인", style: .default) {
            (action :UIAlertAction!in
                print("tapped Ok")
        }
        let noAction : UIAlertAction = UIAlertAction(title: "취소", style: .cancel) {
            (action :UIAlertAction!in
            print("tapped cancel")
        }
        alert.addAction(okAction)
        alert.addAction(noAction)
self.present(alert, animated: true, completion: nil) // 호출
cs


어렵지 않죠?

in 

 //    요기에 필요한 기능들을 넣어주시면 됩니다.

}


이상입니다.

감사합니다.

반응형