iOS/iOS기초(네이버edwith*obj-c)

1001-iOS앱개발 기초> Target Action

soultreemk 2022. 2. 24. 00:50

- 스위치를 끄면 촛불이 꺼지고 스위치를 켜면 촛불이 켜지는 구조

 

1. 코드 구현

UISwitch에서 App Delegate으로 target action을 걸기

AppDelegate.h 에 메소드 선언
AppDelegate.m 에서 메소드 구현

 

2. interface builder에서 연결

 

 

* process 정리 )

target action에 의해 사용자가 스위치를 터치 -> AppDelegate의 touchSwitch가 호출됨 -> sender가 넘어옴

 

 

1. UIImageView, UILabel, UISwitch를 IBOutlet으로 땡겨옴 (-----)

2. UISwitch에서 App Delegate으로 target action을 걺