티스토리 뷰
728x90
요즘 소셜로그인 구현을 해보는 중인데
다들 앱 사용하시다 보면 이런 창 많이 보셨나요!?
alert라고도 불리며, 정확한 명칭은 UIAlertController인데요!
오늘은 alert 메시지 박스 띄우는 걸 구현해 보려고 합니다.
결과

구현 순서
전체적인 흐름은 이렇습니다.
1. 로그아웃 버튼 이벤트를 받을 @IBAction

2. alert창에 띄워질 제목, 메시지, alert유형 세팅


3. alert 버튼 추가


confirm에서의 handler 쪽에 in 뒤에는 '네' 버튼을 눌렀을 때 실행할 이벤트를 적으면 됩니다.
저는 카카오 로그아웃을 시키는 걸 테스트해봤어요.
cancel에서의 handler에선 alert창만 닫으면 되니 아무런 기능이 없는 nil을 넣어줍니다.
4. 3번에서 구현한 버튼을 alert에 등록

5. (alert창, confirm, cancel버튼) 형태를 화면에 출력

이렇게 구현해놓으면 alert의 기능이 구현됩니다!!
React Native를 하다가 iOS를 공부하게 되면서
뭔가 기능 구현을 하려면 접근방법이 비슷한 것 같으면서도 완전 다르게 느껴질 때가 많네요.
이번에 배운 alert를 계기로 다른기능도 가즈아
728x90
'iOS' 카테고리의 다른 글
[iOS] 앱 실행시 TabBar 기본값 지정 (0) | 2021.12.22 |
---|---|
[Swift] 문자열과 문자 (Strings and Characters) (0) | 2021.12.18 |
[Swift] 싱글톤 패턴 (Singleton) (0) | 2021.12.15 |
[Swift] mutating (0) | 2021.12.11 |
[Swift] The Basics (0) | 2021.12.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- iOS error
- Swift final
- Swift Leetcode
- swift protocol
- Swift
- Swift 프로그래머스
- Swift joined()
- Swift 프로퍼티
- Swift Error Handling
- Swift joined
- swift (programmers)
- swift property
- swift programmers
- swift reduce
- 2023년 회고
- RIBs tutorial
- CS 네트워크
- removeLast()
- Swift ModernRIBs
- Swift 내림차순
- ios
- swift 고차함수
- Swift RIBs
- Class
- Swift 알고리즘
- Swift inout
- RTCCameraVideoCapturer
- Swift init
- Combine: Asynchronous Programming with Swift
- 원티드 프리온보딩
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함