일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- ribs
- swiftUI
- Xcode
- RxCocoa
- MVVM
- combine
- Protocol
- UITextView
- 클린 코드
- clean architecture
- map
- tableView
- collectionview
- 리펙터링
- Observable
- Clean Code
- ios
- 애니메이션
- uiscrollview
- UICollectionView
- swift documentation
- HIG
- Human interface guide
- 리팩토링
- Refactoring
- 리펙토링
- rxswift
- uitableview
- SWIFT
- 스위프트
- Today
- Total
목록addAction (2)
김종권의 iOS 앱 개발 알아가기
기존의 UIButton 액션 핸들러 addTarget 메소드의 #selector 부분에 @objc로 정의한 메소드 이름을 넘기는 방식 button.addTarget(self, action: #selector(handleTap), for: .touchUpInside) @objc private func handleTap() { print("tap button!") } addAction 방식의 액션 핸들러 iOS 14+ 부터 addAction 메소드가 UIControl 확장으로 정의 open class UIControl : UIView { /// Adds the UIAction to a given event. UIActions are uniqued based on their identifier, and sub..
일반적인 UIButton의 action 처리 방법 UIButton의 인스턴스 메소드인 addTarge(_:action:for:)를 사용하여 처리 단점은 button의 addTarget하는 부분에서 특정 지역변수에 대한 기능을 touchUpInside 액션 시 동작하게 하기 어려운 점이 존재 아래 abc 지역 프로퍼티를 button의 touchUpInside될 때 출력하고 싶어도 어려운 상태 button의 클로저로 만들면? (아래에서 계속) class ViewController: UIViewController { private let button = UIButton() override func viewDidLoad() { super.viewDidLoad() let abc = 123 button.transl..