[iOS] @IBOutlet

재현·2022년 1월 1일
0
post-thumbnail

@IBOutlet 란?

  1. @ : 어노테이션(Annotation), 프로퍼티(변수 혹은 메서드)의 성질을 알려주는 역할을 함
  2. IB : Interface Builder 의 약자
  3. @IBOutlet :
    1) 코드를 통해 storyboard 의 객체에 접근할 때 사용
    2) 속성 제어시 사용
    3) 유저 인터페이스와 연결되는 프로퍼티
    4) 모디파이어

궁금했던 점

'@IBOutlet 없이 @IBAction 연결 시 action을 수행하나?'라는 부분이 궁금했다.

작동한다!

    @IBOutlet var pressedButton: UIButton!
    @IBAction func pressButton(_ sender: Any) {
        
        let alert = UIAlertController(
            title: "타이틀",
            message: "안녕하세요",
            preferredStyle: .alert
        )
        let ok = UIAlertAction(
            title: "OKtitle",
            style: .default) { action in
            }
        
        alert.addAction(ok)
        present(alert,animated: true, completion: nil)
        
    }

profile
Do Work As We & Respect 🙆🏾 🙆🏻‍♂️ 🙆🏻‍♀️ 🙆‍♀️

0개의 댓글