Swift
[Swift] ViewController와 button Event
응디
2021. 3. 25. 17:31
1. ViewController란?
- 하나의 Screen을 관리한다.
- 따라서 ViewController는 페이지 갯수만큼 존재해야한다.
- storyboard( design ) + storyboard와 연결된 코드 = ViewController
2. Click Event 등록
- button 클릭 시 print("Hello")가 출력 되게 해보자.
- button이 생성되면 해당 button을 ctrl을 누른채 클릭하여 코드로 드래그 시키면 아래와 같이 메소드가 자동 생성
//Connect를 누르면 아래와 같이 코드 생성!
@IBAction func Hello(_ sender: Any){
print("Hello")
}
- 결과확인