很高興看到swift-playground的標籤 - 愛看到這一點繼續。在Swift遊樂場中用MapKit顯示Map以快速查看地圖?
我一直在修補Swift,並且想知道MapKit是否可以在操場中使用,以便您可以使用Quick Look功能,以便我可以迭代並隨時播放我的工作預覽。我還沒有想出語法,所以我想問問是否有人在遊樂場環境中探索過這個問題。我想我需要一些代碼來建立它作爲視圖控制器。
import UIKit
import MapKit
// Sample UIView code which works great in the playground.
//var myView:UIView = UIView();
//myView.frame = CGRectMake(0, 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到init自身等我愛擺弄周圍的解釋遊樂區,只需要弄清楚它是否能夠做到毛澤東的功能,而不是僅僅寫.swift文件和Xcode中的環境,並獲得更多的正式。
http://stackoverflow.com/questions/24108093/how-to-reference-swift-playground-itself?lq=1表明,操場都沒有互動。 –
也許本教程將幫助您找出問題所在:http://www.appshocker.com/swift-programming-ios-101-part-4-mapkit-app-displaying-locations/ –
實際上,它確實顯示錯誤錯誤控制檯添加一行只是mapView,但我不能爲他們的谷歌解決方案。我也試過XCPShowView(「Map」,mapView)沒有運氣 – ReDetection