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 OpenCV 빈 화면 만들기

Python urllib.parse.quote()

Python bytes.fromhex()

Android AVD Ram size change

Forensics .pyc 파일 .py로 복구하기

Android Minimum touch target size

KiCad 시작하기 7 (FreeRoute 사용하기 2)

C++ OpenCV 모폴로지 침식, 팽창

Android Notification with Full Screen

tensorflow tf.expand_dims()