ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 201201 - TIL
    TIL/2021 2020. 12. 2. 01:59

    Swift

     

    오늘 복습한 부분은!!

     

    • Constant & Variable
    • Scope
    • Data type(Int, String, Double ....)
    • Type annotation, Inference, safety, alias
    • Operator
    • Custom Operator, Precedence

     

     


     

    iOS

     

    프로젝트 진행 중에 만난 문제

    Alert의 취소와 확인 순서를 바꾸고 싶다.

    UIAlertController에 addAction메서드로 취소와 확인 UIAlertAction을 추가하는데 추가하는 순서를 바꿔도 취소와 확인이 바뀌지 않았다.

     

     

        func presentTwoButtonAlert(alertTitle: String, message: String, confirmActionTitle: String, cancelActionTitle: String) {
            let twoButtonAlert = UIAlertController(title: alertTitle, message: message, preferredStyle: .alert)
            let confirmAlertAction = UIAlertAction(title: confirmActionTitle, style: .destructive, handler: nil)
            let cancelAlertAction = UIAlertAction(title: cancelActionTitle, style: .cancel, handler: nil)
        
            twoButtonAlert.addAction(confirmAlertAction)
            twoButtonAlert.addAction(cancelAlertAction)
        
            present(twoButtonAlert, animated: true, completion: nil)
        }

    분명 확인을 먼저 추가하고 있는데...?

    헤매던 와중 stackoverflow에서 해답을 찾았다.

    style: .cancel이 문제였다. UIAlerAction.Style이 cancel이라면 내가 원하는 대로 정렬이 안된다.

    해결방법은 아주 간단했다. style을 .default로 바꿔주면 된다.

     

    정상적으로 돌아왔다.

    아주 정상적으로 돌아왔다.

     

     

        func presentTwoButtonAlert(alertTitle: String, message: String, confirmActionTitle: String, cancelActionTitle: String) {
            let twoButtonAlert = UIAlertController(title: alertTitle, message: message, preferredStyle: .alert)
            let confirmAlertAction = UIAlertAction(title: confirmActionTitle, style: .destructive, handler: nil)
            let cancelAlertAction = UIAlertAction(title: cancelActionTitle, style: .default, handler: nil)
        
            twoButtonAlert.addAction(confirmAlertAction)
            twoButtonAlert.addAction(cancelAlertAction)
        
            present(twoButtonAlert, animated: true, completion: nil)
        }

     

     

     

     

    awakeFormNib이 궁금해서 공부하던 중에 ViewController의 생명 주기까지 보게 됐다.

    • loadView
    • viewDidLoad
    • viewWillAppear
    • viewDidAppear
    • viewWillDisappear
    • viewDidDisappear
    • viewDidUnload

     

    여기서 awakeFromNib은 viewDidLoad와 viewWillAppear사이에서 실행이 된다고 한다.

    공식문서를 읽어봐도 이해가 가지 않는 부분이 많다..

     

     


     

     

    그 외

     

    오늘은 레츠스위프트 2일차 오늘은 SwiftUI와 UIKit에 대한 주제였다.

    아직 SwiftUI를 배우지 않아서 많은 부분을 이해할 수 없었지만 이러한 게 있구나 라는 것을 알아가는 계기가 됐다.

    그리고 패널로 참가하신 이봉원 님의 설명도 너무 좋았다.

    과연 최소 배포 버전이 iOS 14.0이 되는 때에 SwiftUI가 많이 쓰일까?? 그전까지 UIKit을 완벽히 알아가고 SwiftUI도 어서 공부해야겠다!

     

     

    LetSwift at Home

    2020 레츠스위프트는 집에서 함께 할 수 있습니다.

    letswift.kr

     

    728x90

    'TIL > 2021' 카테고리의 다른 글

    201210 - TIL  (0) 2020.12.11
    201207 - TIL  (0) 2020.12.08
    201130 - TIL  (0) 2020.12.01
    201128 - TIL  (0) 2020.11.29
    201127 - TIL  (0) 2020.11.28
Designed by Tistory.