2
我想放大PinImages在圖形頁面(當它縮小或放大)雨燕數組元素類型,爲了這個,我做的事:NSArray的元素沒有匹配mapView.annotations環
func resizePin(scale: CGFloat, image: UIImage) -> UIImage {
var newSize = CGSizeMake(image.size.width * scale, image.size.height * scale)
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
image.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height))
var newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
在委託方法後我發現的規模和想使用resizePin方法的MapView註釋的循環內,調整它們的大小都
func mapView(mapView: MKMapView!, regionWillChangeAnimated animated: Bool) {
oldZoomLatitude = mapView.region.span.latitudeDelta
oldZoomLongitude = mapView.region.span.longitudeDelta
}
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {
newZoomLatitude = mapView.region.span.latitudeDelta
newZoomLongitude = mapView.region.span.longitudeDelta
mapScale = (newZoomLongitude!/oldZoomLongitude!)
println(mapScale)
for annotation in mapView.annotations as [MKAnnotationView] { // EXCEPTION - fatal error: NSArray element failed to match the Swift Array Element type
}
}
不明白如何作出正確的,什麼是例外的一個原因。有任何想法嗎?