スウィフトでピン位置(zPosition)をTopに設定しようとしましたが、現在のピン(任意のピン)が上に表示され、現在のピン画像が変化しています、しかし、そのトップに表示されない、ここで私を助けてください、私のコード である私は、これらのコードスウィフトviewForAnnotationピン配置が上にない
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
アプリのクラッシュこれらのライン上の
pinView!.superview!.bringSubviewToFront(view)
とその私に 致命的なエラーを返してみていますが予期せずアンラッピング中に見つからないオプションの値 ここでトップ
にショーを固定するためにどのように私を助けてくださいは、我々はすべての10本のピンを表示するようにズームを選択することができ、私はもう一つの問題を抱えている私のコード
func mapView(mapView: MKMapView,
viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{
if annotation is MyAnnotation == false{
return nil
}
/* First typecast the annotation for which the Map View has
fired this delegate message */
let senderAnnotation = annotation as! MyAnnotation
// -------------------------- For ios 9 -------------------
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if pinView == nil {
pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
}else{
pinView!.annotation = annotation
}
pinView!.tag = senderAnnotation.getTag;
// print(senderAnnotation.getTag)
if annotation is MyAnnotation {
print(senderAnnotation.pinColor)
if(senderAnnotation.pinColor == .Red)
{
if(currentIndex == senderAnnotation.getTag)
{
print("currentIndex==\(currentIndex)********")
pinView!.image = UIImage(named: "jivemap_pin_rough_o.png")
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
}else
{
pinView!.image = UIImage(named: "jivemap_pin_rough_g.png")
}
}
else
{
if(currentIndex == senderAnnotation.getTag)
{
print("currentIndex==*********\(currentIndex)********")
pinView!.image = UIImage(named: "jivemap_pin_o.png")
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
}else
{
pinView!.image = UIImage(named: "jivemap_pin_g.png")
}
}
pinView!.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView
// pinView
// return pinView
}
return pinView
//return annotationView
}
で一緒にどれでも解決方法ズームレバーの設定方法は、マップビューの全10ピンを表示するカメラレベル これらのポイントを検索すると、これらのコードが見つかりましたが、これらのコードの使い方を理解することはできません。
CGFloat latDelta = rand()*0.125/RAND_MAX - 0.02;
CGFloat lonDelta = rand()*0.130/RAND_MAX - 0.08;
CGFloat lat = 59.189358;
CGFloat lng = 18.267839;
CLLocationCoordinate2D newCoord = {lat+latDelta, lng+lonDelta};
DTSAnnotation *annotation = [DTSAnnotation annotationWithCoord:newCoord];
私はそれと同じ問題を持っていた最初のポイントについて関連マップ ありがとう
多分、いくつかのスクリーンショットが役に立ちます。 – Lumialxk
OK私は追加しますが、問題は10ピン9ピンが同じで、1ピンが別のイメージなので、これらのピンは他のピンに戻したくありません。 –