在Swift游乐场中使用MapKit显示地图以便快速查看?

在Swift游乐场中使用MapKit显示地图以便快速查看?,第1张

概述很高兴看到swift-playground的标签 – 喜欢看到这种情况继续下去。 我一直在修补Swift,我想知道MapKit是否可以在 *** 场上使用,这样你就可以使用Quick Look功能,这样我就可以迭代并使用我的工作预览。我还没想出语法,所以我想问一下是否有人在游乐场环境中探讨过这个问题。我想我需要一些代码来建立它作为一个视图控制器。 import UIKitimport MapKit/ 很高兴看到swift-playground的标签 – 喜欢看到这种情况继续下去。

我一直在修补Swift,我想知道MapKit是否可以在 *** 场上使用,这样你就可以使用Quick Look功能,这样我就可以迭代并使用我的工作预览。我还没想出语法,所以我想问一下是否有人在游乐场环境中探讨过这个问题。我想我需要一些代码来建立它作为一个视图控制器。

import UIKitimport MapKit// Sample UIVIEw code which works great in the playground.//var myVIEw:UIVIEw = UIVIEw();//myVIEw.frame = CGRectMake(0,320,560)//myVIEw.backgroundcolor = UIcolor.bluecolor()// Non working map code - no errors but can't figure out what to call or initiate to get the vIEw in the Quick Look sIDe.var mapVIEw = MKMapVIEw();mapVIEw.region.center.latitude = mapVIEw.userLocation.coordinate.latitude;mapVIEw.region.center.longitude = mapVIEw.userLocation.coordinate.longitude;mapVIEw.region.span.latitudeDelta = 0.00725;mapVIEw.region.span.longitudeDelta = 0.00725;

猜测我只是缺少一些简单的mapVIEw来初始化自己等等。我喜欢解释的游乐场区域进行修补,只需要弄清楚它是否可以执行mao功能,而不是仅仅在Xcode中编写.swift文件和环境并获取更正式。

对于OS X上的XCode7.1和Swift2.1,我打开了时间轴并执行了以下 *** 作:
import MapKitimport XCPlaygroundlet delta = 5.0let frame = CGRect( x:0,y:0,wIDth:200,height:200 )let mapVIEw = MKMapVIEw( frame: frame )var region = MKCoordinateRegion()region.center.latitude = 31.0region.center.longitude = -110.0region.span.latitudeDelta = deltaregion.span.longitudeDelta = deltamapVIEw.setRegion( region,animated: true )XCPlaygroundPage.currentPage.liveVIEw = mapVIEwXCPlaygroundPage.currentPage.needsIndefiniteExecution = true

Xcode 9.x,Swift 4.1更新:

导入PlaygroundSupport
导入MapKit

let delta = 5.0let frame = CGRect( x:0,animated: true )PlaygroundPage.current.liveVIEw = mapVIEwPlaygroundPage.current.needsIndefiniteExecution = true
总结

以上是内存溢出为你收集整理的在Swift游乐场中使用MapKit显示地图以便快速查看?全部内容,希望文章能够帮你解决在Swift游乐场中使用MapKit显示地图以便快速查看?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1052185.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存