학습하기
컨트롤 이벤트와 액션과의 관계
UIKit에는 UIButton
, UISwitch
, UIStepper
등 UIControl
을 상속받은 다양한 컨트롤 클래스가 있습니다. 그런 컨트롤 객체에 발생한 다양한 이벤트 종류를 특정 액션 메서드에 연결할 수 있습니다. 즉, 컨트롤 객체에서 특정 이벤트가 발생하면, 미리 지정해 둔 타겟의 액션을 호출하게 됩니다.
컨트롤 이벤트의 종류
컨트롤 이벤트는 UIControl에 Event라는 타입으로 정의되어 있습니다. 아래는 컨트롤 객체에 발생할 수 있는 이벤트의 종류입니다. 다양한 이벤트 종류를 실제로 Xcode에서 테스트해보면 이해하는데 도움이 될거에요!
touchDown
컨트롤을 터치했을 때 발생하는 이벤트
UIControl.Event.touchDown
touchDownRepeat
컨트롤을 연속 터치 할 때 발생하는 이벤트
UIControl.Event.touchDownRepeat
touchDragInside
컨트롤 범위 내에서 터치한 영역을 드래그 할 때 발생하는 이벤트
UIControl.Event.touchDragInside
touchDragOutside
터치 영역이 컨트롤의 바깥쪽에서 드래그 할 때 발생하는 이벤트
UIControl.Event.touchDragOutside
touchDragEnter
터치 영역이 컨트롤의 일정 영역 바깥쪽으로 나갔다가 다시 들어왔을 때 발생하는 이벤트
UIControl.Event.touchDragEnter
touchDragExit
터치 영역이 컨트롤의 일정 영역 바깥쪽으로 나갔을 때 발생하는 이벤트
UIControl.Event.touchDragExit
touchUpInside
컨트롤 영역 안쪽에서 터치 후 뗐을때 발생하는 이벤트
UIControl.Event.touchUpInside
touchUpOutside
컨트롤 영역 안쪽에서 터치 후 컨트롤 밖에서 뗐을때 이벤트
UIControl.Event.touchUpOutside
touchCancel
터치를 취소하는 이벤트 (touchUp 이벤트가 발생되지 않음)
UIControl.Event.touchCancel
valueChanged
터치를 드래그 및 다른 방법으로 조작하여 값이 변경되었을때 발생하는 이벤트
UIControl.Event.valueChanged
primaryActionTriggered
버튼이 눌릴때 발생하는 이벤트 (iOS보다는 tvOS에서 사용)
UIControl.Event.primaryActionTriggered
editingDidBegin
UITextField에서 편집이 시작될 때 호출되는 이벤트
UIControl.Event.editingDidBegin
editingChanged
UITextField에서 값이 바뀔 때마다 호출되는 이벤트
UIControl.Event.editingChanged
editingDidEnd
UITextField에서 외부객체와의 상호작용으로 인해 편집이 종료되었을 때 발생하는 이벤트
UIControl.Event.editingDidEnd
editingDidEndOnExit
UITextField의 편집상태에서 키보드의 return 키를 터치했을 때 발생하는 이벤트
UIControl.Event.editingDidEndOnExit
allTouchEvents
모든 터치 이벤트
UIControl.Event.allTouchEvents
allEditingEvents
UITextField에서 편집작업의 이벤트
UIControl.Event.allEditingEvents
applicationReserved
각각의 애플리케이션에서 프로그래머가 임의로 지정할 수 있는 이벤트 값의 범위
UIControl.Event.applicationReserved
systemReserved
프레임워크 내에서 사용하는 예약된 이벤트 값의 범위
UIControl.Event.systemReserved
allEvents
시스템 이벤트를 포함한 모든 이벤트
UIControl.Event.allEvents
comment
에셋에서 (설치폴더들)/Assets.xcassets: Accent color ‘AccentColor’ is not present in any asset catalogs. 이런 오류가
메인에서(설치폴더들)/MusicPlayer/Base.lproj/Main.storyboard Views without any layout constraints may clip their content or overlap other views.이러한 오류가
뷰컨트롤러에서 (설치폴더들)/MusicPlayer/Base.lproj/Main.storyboard “View Controller“ is unreachable because it has no entry points, and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:]. 이러한 오류가 나오네요
엑스코드가 14.3이라 그런가.. 뭐가문제인지 알기가 어렵네요
스토리보드에서 control 누른채로 드래그하셔야 강의처럼 액션 펑션이 만들어지네요. 이후에 듣는 분들 참고하세요~
알찬 강의 감사합니다 야곰님
강사님처럼 xcode 화면과 simulater 분할해서 보려면 어떻게 하나요?
3분 40초~ 4분 15초 경에 그림 끌어다가 액션 펑션 만드는 방법 설명 가능 하신가요?? 어시스턴트 열고 그림 끌어다가 코드쪽에 가져가려 하면 그림의 위치를 이동 시키는 식이 되어서 질문 드립니다.
와 너뮤 감사합니다 :)
5분 30초 쯤에서 질문드립니다.
시뮬레이터에 마우스 커서 갖다대시니 동그란 원이 마우스 커서 따라 다니네요.
그 기능 쓰고 싶은데 어떻게 하면 좋을까요...
Target Action에 대해 올라온 링크가 잘못된 것 같습니다.
https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/Target-Action/Target-Action.html
로 수정부탁드립니다.