私は、スピーディーでオブジェクト指向のプログラミングには新しく、マップを含むビューから別のビューにビューを切り替えようとしています。長い押しで落とされたピンの注釈の右のアクセサリコールアウトボタン。ストーリーボードでは、私は2つのビューの間にセグを作成し、識別子mapsegでセグを割り当てました。残念ながら、私はGoogle経由で見つけることができたすべてを試した後、右のアクセサリーの吹き出しボタンをタップして理由がわからないときにセグを得ることができません。アプリケーション自体はタブ付きのタブ付きアプリケーションです。 2番目のタブのビューはマップを含むビューです。また、これが何かと関係するかどうかはわかりませんが、移行しようとしているビューはナビゲーションコントローラに組み込まれています。ここから移行しようとしているビューのコードです。地図の注釈で右のアクセサリのコールアウトボタンをタップしてビューを分割する方法をスピーディーにする
import UIKit
import MapKit
class SecondViewController: UIViewController, MKMapViewDelegate {
@IBOutlet weak var MapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
self.MapView.delegate = self
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let reuseID = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseID) as? MKPinAnnotationView
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseID)
pinView!.canShowCallout = true
pinView!.animatesDrop = true
pinView!.enabled=true
let btn = UIButton(type: .DetailDisclosure)
btn.titleForState(UIControlState.Normal)
pinView!.rightCalloutAccessoryView = btn as UIView
return pinView
}
@IBAction func dropPin(sender: UILongPressGestureRecognizer) {
if sender.state == UIGestureRecognizerState.Began {
let location = sender.locationInView(self.MapView)
let locCoord = self.MapView.convertPoint(location, toCoordinateFromView: self.MapView)
let annotation = MKPointAnnotation()
annotation.coordinate = locCoord
annotation.title = "City Name"
annotation.subtitle = ""
self.MapView.removeAnnotations(MapView.annotations)
self.MapView.addAnnotation(annotation)
self.MapView.selectAnnotation(annotation, animated: true)
}
func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == view.rightCalloutAccessoryView {
self.performSegueWithIdentifier("mapseg", sender: self)
}
}
}
}
これを取得するために使用したprepareForSequeコードを投稿できますか? – cfsprod