微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法打开具有不同尾部小部件 SwiftUI 的深层链接

如何解决无法打开具有不同尾部小部件 SwiftUI 的深层链接

我在fidget中设置了四个按钮,每个按钮打开Deeplink的尾部不同,然后我在SceneDelegate里面处理Deeplink,但是每次在SceneDelegate里面处理Deeplink时,每个Deeplink都一样,为什么?

我的代码

struct WidgetTestEntryView : View {
    var entry: Provider.Entry
    
    var deeplinkURLFirst: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/0")!
    }
    var deeplinkURLSecond: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/1")!
    }
    
    var deeplinkURLThird: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/2")!
    }
    
    var deeplinkURLFourty: URL {
        URL(string: "widget-DeepLinkWidget://widgetFamily/3")!
    }
    
    var widgetLabel = "Favourites"

    var body: some View {
        
       
        
        vstack {
            HStack(spacing: 100){
                Text(widgetLabel).foregroundColor(.white).font(.system(size: 16,weight: .bold,design: .default)).offset(y: 2)
                Image("Label").resizable().frame(width: 80,height: 15,alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                
            }.frame(maxWidth: .infinity,maxHeight: 50,alignment: .center).background(Color.black).offset(y: -9)
            
            HStack {
                Spacer()
                Button(action: {}) {
                    
                    Image(imageFromAppGroup(key: "image0")).resizable().frame(width: 70,height: 70)
                        .cornerRadius(10)
                        .background(Color(red: 0.218,green: 0.215,blue: 0.25))
                    
                }.widgetURL(deeplinkURLFirst).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image1")).resizable().frame(width: 70,blue: 0.25))
                }.widgetURL(deeplinkURLSecond).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image2")).resizable().frame(width: 70,blue: 0.25))
                }.widgetURL(deeplinkURLThird).cornerRadius(10)

                Button(action: {}) {
                    Image(imageFromAppGroup(key: "image3")).resizable().frame(width: 70,blue: 0.25))
                }.widgetURL(deeplinkURLFourty).cornerRadius(10)

                Spacer().frame(width: 10,height: 10,alignment: .center)
                
            }.background(Color(red: 0.118,green: 0.118,blue: 0.15)).offset(y: -9)
            
            
        }.frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .center).background(Color(red: 0.118,blue: 0.15)).onAppear {
            print("I AM HERE !!!")
            
        }
    }
}

控制台日志:

widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3
widget-DeepLinkWidget://widgetFamily/3

必须是:

widget-DeepLinkWidget://widgetFamily/0
widget-DeepLinkWidget://widgetFamily/1
widget-DeepLinkWidget://widgetFamily/2
widget-DeepLinkWidget://widgetFamily/3

索引的结尾取决于特定的按钮。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。