ν‹°μŠ€ν† λ¦¬ λ·°

728x90
λ°˜μ‘ν˜•

πŸ‘‰ μœ„μ ―μ„ 톡해 μ•±μ˜ νŠΉμ • 뷰둜 이동

  • QR Code μœ„μ ―μ„ μ„ νƒν•˜λ©΄ μ•„λž˜μ™€ 같이 ν™”λ©΄μ „ν™˜μ΄ 적용된 QR Code 인식 뷰둜 μ΄λ™ν•˜λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€.
μŠ€ν¬λ¦°μƒ· 2022-12-02 μ˜€μ „ 11 30 28

πŸ‘‰ widgetURL(_:)

μœ„μ ―μ„ ν΄λ¦­ν–ˆμ„ λ•Œ containing app μ—μ„œ 열릴 URL 을 μ„€μ •ν•©λ‹ˆλ‹€.

Overview

widgetURL modifier λŠ” view hierarchy μ—μ„œ ν•˜λ‚˜λ§Œ μ§€μ›ν•©λ‹ˆλ‹€. μ—¬λŸ¬ 뷰에 widgetURL 이 μžˆλŠ” 경우 λ™μž‘μ΄ μ •μ˜λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

struct QRCodeEnytryView : View {
    var entry: QRCodeProvider.Entry

    var body: some View {
        Image("widgetQr")
            .resizable()
            .scaledToFill()
            // βœ…
            .widgetURL(URL(string: "openQRCode"))
    }
}

πŸ‘‰ scene(_:openURLContexts:)

Asks the delegate to open one or more URLs.

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        let qrcodeURL: String = "openQRCode"

        guard let url = URLContexts.first?.url,
              let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: true) else { return }

        if qrcodeURL == urlComponents.path {
            guard let nextViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NextViewController") as? NextViewController else { return }
            window?.rootViewController?.present(nextViewController, animated: true, completion: nil)
        }
    }

widgetURL 둜 μ„€μ •ν•œ URL 이 λ“€μ–΄μ˜€κ²Œ 되면 containing app 의 νŠΉμ • 뷰둜 ν™”λ©΄μ „ν™˜ν•˜λ„λ‘ ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

728x90
λ°˜μ‘ν˜•
λŒ“κΈ€
μ΅œκ·Όμ— 올라온 κΈ€
μ΅œκ·Όμ— 달린 λŒ“κΈ€
κΈ€ 보관함
Β«   2024/11   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
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 29 30
링크
Total
Today
Yesterday