0
私は何十もの注釈を持つ地図を持っています。アノテーションにはタイトルとサブタイトルが正しく表示されています。その右側にカスタムの[移動]ボタンを追加します。 [Go]ボタンをクリックすると、Apple Mapsが開き、地図上で見ていたアノテーションをユーザーに指示できます。map注釈は表示されませんrightCalloutAccessoryViewのカスタムUIButton
下記のコードをコピーしました。現在のフォームでは、ボタンは表示されません。
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if !(annotation is MKUserLocation) {
let pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: String(annotation.hash))
let rightButton = UIButton(type: .custom)
rightButton.setImage(UIImage(named: "Go"), for: .normal)
rightButton.tag = annotation.hash
pinView.canShowCallout = true
pinView.rightCalloutAccessoryView = rightButton
return pinView
}
else {
return nil
}
}
私は次の行削除する場合:
rightButton.setImage(UIImage(named: "Go"), for: .normal)
をし、それを超えるものを変更します。それはとの問題だと私に語った、
let rightButton = UIButton(type: .detailDisclosure)
は、ボタンが正しく表示されませんボタンのカスタムイメージを使用しようとしました。
何が欠けているのですか?