首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SwiftUI崩溃<<<opaque返回类型的View.contextMenu<A>(menuItems:)>>

SwiftUI崩溃<<<opaque返回类型的View.contextMenu<A>(menuItems:)>>
EN

Stack Overflow用户
提问于 2021-12-23 10:03:17
回答 1查看 107关注 0票数 0

我注意到了一些崩溃,但我确实找不到造成崩溃的任何具体原因,Xcode也没有帮助我识别它。QueryLogView.body.getterActiveInstance.swift:43都是代码中的空行,我不知道closure in closure in closure能告诉我什么。

也许这与report partial apply...中的第3行有关。有人知道去哪里找吗?

代码语言:javascript
复制
Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000101138968
Exception Note:  EXC_CORPSE_NOTIFY
Terminating Process: exc handler [23436]
Triggered by Thread:  0


Thread 0 name:
Thread 0 Crashed:
0   Pi-hole Remote                  0x0000000101138968 closure #5 in closure #1 in closure #1 in closure #2 in closure #1 in QueryLogView.body.getter + 316 (<compiler-generated>:0)
1   Pi-hole Remote                  0x00000001011388b8 closure #5 in closure #1 in closure #1 in closure #2 in closure #1 in QueryLogView.body.getter + 140 (QueryLogView.swift:0)
2   Pi-hole Remote                  0x000000010114b49c partial apply for thunk for @escaping @callee_guaranteed (@guaranteed [String]) -> (@out _ConditionalContent<AnyView, NavigationLink<<<opaque return type of View.contextMenu<A>(menuItems:)>>.0, Mod... + 24 (<compiler-generated>:0)
3   SwiftUI                         0x0000000188257740 ForEachChild.updateValue() + 1412 (ForEach.swift:1150)
4   SwiftUI                         0x00000001882588e4 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init<A>(_:) + 32 (<compiler-generated>:0)
...
114 UIKitCore                       0x0000000182e5b958 UIApplicationMain + 2092 (UIApplication.m:5046)
115 Pi-hole Remote                  0x0000000100fd527c main + 68 (ActiveInstance.swift:43)
116 dyld                            0x0000000101a81aa4 start + 520 (dyldMain.cpp:879)

编辑:

这是QueryLogView内部的代码,我在其中使用一个.contextMenu

代码语言:javascript
复制
ForEach(filterQueries(array: queries.data), id: \.self) { query in
    NavigationLink(destination: QueryDetailView(query: query, instance: intIDtoInstance(Int(query.last ?? "1"))).environmentObject(self.state)) {
        QueryRow(headline: .all, instance: self.activeInstance, query: query)
            .contextMenu {
                Section {
                    Button(action: {
                        self.showSheet = .queriesToDomain(query[2])
                    }) {
                        Text("view_queries_to_domain")
                        Image(systemName: "doc.text.magnifyingglass")
                    }
                    Button(action: {
                        self.showSheet = .queriesToClient(query[3])
                    }) {
                        Text("view_queries_from_client")
                        Image(systemName: "doc.text.magnifyingglass")
                    }
                }
                Section {
                    if #available(iOS 14.0, *) {
                        if let domainURL = URL(string: "https://\(query[2])") {
                            Link(destination: domainURL, label: {
                                Text("visit_domain")
                                Image(systemName: "network")
                            })
                        }
                    }
                    Button(action: {
                        UIPasteboard.general.string = query[2]
                    }) {
                        Text("copy_domain")
                        Image(systemName: "doc.on.doc")
                    }
                    Button(action: {
                        UIPasteboard.general.string = query[3]
                    }) {
                        Text("copy_hostname_or_ip")
                        Image(systemName: "doc.on.doc")
                    }
                }
                Section {
                    Button(action: {
                        addToList(query)
                    }) {
                        Text("add_to_list_dots")
                        Image(systemName: "shield.lefthalf.fill")
                    }
                }
            }
    }.modify {
        if #available(iOS 15.0, *) {
            $0.swipeActions(edge: .leading, allowsFullSwipe: true) {
                Button {
                    addToList(query)
                } label: {
                    Label(queryToListTuple(query).list, systemImage: "shield.lefthalf.fill")
                }.tint(queryToListTuple(query).color)
            }
        } else {
            $0
        }
    }
    #if targetEnvironment(macCatalyst)
    .padding(.horizontal, -12)
    #endif
}

.modify用于具有基于iOS版本的条件修饰符:

代码语言:javascript
复制
extension View {
    func modify<T: View>(@ViewBuilder _ modifier: (Self) -> T) -> some View {
        return modifier(self)
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-07 20:50:28

发现删除所有发生的.modify修复了崩溃。不知道到底出了什么问题,但它似乎解决了问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70460512

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档