要获得UIViewRepresentable结构的预览,我有以下代码:
import SwiftUI
import WidgetKit
struct ViewRepresentable: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
return UIView()
}
func updateUIView(_ uiView: UIView, context: Context) {
}
typealias UIViewType = UIView
}
struct ViewRepresentable_Previews: PreviewProvider {
static var previews: some View {
ViewRepresentable().previewContext(WidgetPreviewContext(family: .systemSmall))
}
}它输出以下诊断信息。
RemoteHumanReadableError: Failed to update preview
invalid TimelineEntries错误是“无法在此文件中预览-未能更新预览”。
如何解决这个错误?
发布于 2021-06-25 15:47:58
包装在
UIKit视图中的UIViewRepresentable不能在WidgetKit中工作。
来源:https://developer.apple.com/forums/thread/653471?answerId=619627022#619627022
https://stackoverflow.com/questions/68119387
复制相似问题