Xcode 15b3中SwiftUI MapKit的lookAroundViewer是否已实现?
Xcode 15b3中
.lookAroundViewer修饰符无法识别的问题 .lookAroundViewer(isPresented:initialScene:)视图修饰符在Xcode 15 Beta 3中并未实际实现,苹果官方文档的内容有时会超前于SDK的实际交付进度,出现文档已更新但对应API尚未在测试版中上线的情况。
目前你采用的popover结合LookAroundPreview的实现方式是当前测试版下的可行方案,代码逻辑无问题。如果后续正式版或更新的测试版中该修饰符上线,调用方式应和文档描述一致,需确保:
- 已导入
MapKit框架 - 目标iOS版本设置为iOS 17+(该API属于iOS 17新增功能)
你的当前可运行代码:
@State private var lookAroundScene: MKLookAroundScene? @State private var isLookingAround = false var body: some View { VStack { item.image .resizable() .aspectRatio(contentMode: .fill) //.lookAroundViewer(isPresented: $isLookingAround, initialScene: lookAroundScene) //<--- 暂未实现 if lookAroundScene.exists { Button(systemImage: "binoculars") { isLookingAround = true } } } .onAppear(perform: getLookAroundScene) .popover(isPresented: $isLookingAround) { LookAroundPreview(initialScene: lookAroundScene) } } private func getLookAroundScene() { lookAroundScene = nil Task { let request = MKLookAroundSceneRequest(coordinate: item.coordinate) lookAroundScene = try? await request.scene } }
后续若该修饰符正式上线,直接取消注释并确保参数正确即可,无需额外复杂配置。
内容的提问来源于stack exchange,提问作者Grimxn
相关产品推荐
相关产品推荐

