iOS How to notice app is will enter foreground

운영 체제: macOS Ventura 13.0.1
사용 버전: Xcode 14.2, Swift, SwiftUI

iOS How to notice app is will enter foreground를 알아보겠습니다.

SwiftUI에는 AppDelegate, SceneDelegate가 없기 때문에 foreground 상태로 들어오는 타이밍을 알기 어렵습니다. 이럴 때 onReceive를 사용해서 알 수 있습니다.


아래와 같은 App이 있습니다.







.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in }를 적어줍니다.





끝.


카테고리: iOS

댓글

이 블로그의 인기 게시물

Python urllib.parse.quote()

Python bs4.SoupStrainer()

Python OpenCV 빈 화면 만들기

Android Minimum touch target size

KiCad 시작하기 2 (PCB 만들기)

Android Release Apk 만들기

KiCad 시작하기 5 (만든 PCB 주문하기)

Android Notification with Full Screen

KiCad 시작하기 4 (기존 회로도 수정 및 추가)

tensorflow tf.expand_dims()