无法在范围内找到可表示的 uiviewcontroller
我的应用程序有一个 WatchKit 扩展,我需要使用手机上应用程序的更新来修改内容视图中的数据。所以我使用下面的代码...但是编译器错误说它可以在范围内找到 UViewControllerRepresentable
struct ContentView: View, UViewControllerRepresentable
{
var body: some View {
VStack
{
...
}
}
I have a WatchKit extension to my app and I need to modify the data in the content view with updates from the app on the phone. So I am using the code below... but the compiler errors out saying it can find UViewControllerRepresentable in scope
struct ContentView: View, UViewControllerRepresentable
{
var body: some View {
VStack
{
...
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIViewControllerRepresentable
不可用于观看。https://developer.apple.com/documentation/swiftui/uiviewcontrollerrepresentable
没有需要,因为 WatchKit/WatchOS 没有
UIViewController
https://developer.apple.com/documentation/uikit/uiviewcontroller
SwiftUI
View
可用,但你不能使用UIKit
的UIView
s/UIViewController
s每当你必须重新设计一个对于 watchOS 兼容版本的
View
,您可以将其命名为与iOS
目标版本相同的名称,并为其指定相同的init
。如果您正确选择目标成员资格,编译器将选择当前目标的版本。
UIViewControllerRepresentable
is not available for watch.https://developer.apple.com/documentation/swiftui/uiviewcontrollerrepresentable
There is no need because WatchKit/WatchOS doesn't have
UIViewController
shttps://developer.apple.com/documentation/uikit/uiviewcontroller
SwiftUI
View
s are available but you can't useUIKit
'sUIView
s/UIViewController
sWhenever you have to redesign a
View
for a watchOS compatible version you can name it the same as theiOS
target's version and give it the sameinit
.If you keep the target memberships selected appropriately the compiler will chose the current target's version.