You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 18:50:08