๐ฑ iOS/-- UIKit (iOS) UIControl ๊ณตํต ๊ฐ๋ - Target Action , selector - UIControl ์ ์ข ๋ฅ Button Switch Slider Page Control Date Picker Segmented Control Stepper UIControl & Taget-Action UIControl์ UIView์ ํ์ํด๋์ค์ด๋ฉฐ, ๊ทธ ๋ฐ์ UIButton, UISwitch... ๋ฑ์ ์ปจํธ๋กค๋ฑ์ด ์กด์ฌํ๋ค. ์ปจํธ๋กค๋ค์ ์ฌ์ฉ์์ ํฐ์น(์ด๋ฒคํธ)์ ๋ฐ๋ผ Target-Action ๋งค์ปค๋์ฆ์ผ๋ก ๋์ํ๊ฒ ๋๋ค. Target ์ง์ ์ addTarget(_:action:for:) ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ค. ์ก์ ๋ฉ์๋๋ ์ธ๊ฐ์ง ํ์์ด ์๋ค. @IBAction func doSomething() @IBAction func doSomething(sender : UIButton) @IBAction func doSomething(sender : UIButton, forEvent event : UIEvent) ์ปจํธ๋กค์ ํด๋นํ๋ sender๋ ๋ฉ์๋๋ฅผ ํธ์ถํ๋ ์ญํ ์ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ์ด๋ฒคํธ ํ๋ผ๋ฏธํฐ์ ํด๋นํ๋ UIEvent ๊ฐ์ฒด๋ ์ด๋ฒคํธ์ ํธ๋ฆฌ๊ฑฐ๊ฐ ๋๋ค. import UIKit class UIViewController { } Selector ์ addTarget ์ ์ฌ์ฉํ์ฌ target ์ฐ๊ฒฐ ์์ (์คํ ๋ฆฌ ๋ณด๋์์๋ ๋ฒํผ๊ณผ button๋ณ์๋ง Outlet ์ฐ๊ฒฐ์ ํด์ค๋ค.) import UIKit class ViewController: UIViewController { @IBOutlet weak var button: UIButton! @objc func buttonAction(_ sender : Any){ print(#function) } override func viewDidLoad() { super.viewDidLoad() let actionSelector = #selector(buttonAction(_:)) button.addTarget(self, action: actionSelector, for: .touchUpInside) } } #selector๋ ์ค๋ธ์ ํธ-c ์์ ์ฌ์ฉ๋๋๊ฒ์ด๊ธฐ ๋๋ฌธ์ ์ ํํ ํจ์ ์์ @objc๋ฅผ ๋ถ์ฌ์ค์ผํ๋ค. ๊ณต์ ํ๊ธฐ URL ๋ณต์ฌ์นด์นด์คํก ๊ณต์ ํ์ด์ค๋ถ ๊ณต์ ์์ค ๊ณต์ ๊ฒ์๊ธ ๊ด๋ฆฌ ๊ตฌ๋ ํ๊ธฐnewmon Contents UIControl์์ข ๋ฅ UIControl&Taget-Action Selector์addTarget์์ฌ์ฉํ์ฌtarget์ฐ๊ฒฐ์์ ๋น์ ์ด ์ข์ํ ๋งํ ์ฝํ ์ธ (iOS) UIControl - Picker View 2021.06.02 (iOS) UIControl - Button 2021.06.02 (iOS) ๋ธ๋ฆฌ๊ฒ์ดํธ ํจํด (Delegate Pattern , tableView , TextField, ํ๋ฉด๊ฐ ๋ฐ์ดํฐ ์ ๋ฌ) 2021.05.21 (iOS) ํ๋ฉด ์ ํ ๋ฐฉ์ (present, pushViewController, Segue) 2021.05.14 ๋๊ธ 0 + ์ด์ ๋๊ธ ๋๋ณด๊ธฐ