[英]SwiftUI crashing <<<opaque return type of View.contextMenu<A>(menuItems:)>>
I'm noticing some crashes but I really can't seem to find any specific cause of the crash, nor is Xcode helping me identify it.我注意到一些崩溃,但我似乎真的找不到崩溃的任何具体原因,Xcode 也没有帮助我识别它。 Both the QueryLogView.body.getter
and ActiveInstance.swift:43
are empty lines in the code, and I'm not sure what closure in closure in closure
can tell me. QueryLogView.body.getter
和ActiveInstance.swift:43
都是代码中的空行,我不确定closure in closure in closure
能告诉我什么。
Perhaps it has something to do with the 3rd line in the report partial apply...
.也许它与报告中的第 3 行partial apply...
Does someone know where to look?有人知道在哪里看吗?
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)
EDIT:编辑:
This is the code inside QueryLogView
where I use a .contextMenu
:这是QueryLogView
中我使用.contextMenu
的代码:
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
is used to have conditional modifiers based on iOS versions: .modify
用于具有基于 iOS 版本的条件修饰符:
extension View {
func modify<T: View>(@ViewBuilder _ modifier: (Self) -> T) -> some View {
return modifier(self)
}
}
Found out that removing all occurrences of .modify
fixed the crashes.发现删除所有出现的.modify
修复了崩溃。 No idea what was actually going wrong, but it seems to fix it.不知道实际上出了什么问题,但它似乎可以解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.