저는 신속하고 객체 지향 프로그래밍에 익숙하지 않고,지도가 포함 된 뷰에서 다른 뷰로 뷰를 전환하려고합니다. 긴 누르기로 떨어 뜨린 핀의 주석에 오른쪽 액세서리 콜 아웃 버튼. 스토리 보드에서 나는 두 개의 뷰 사이에 단절을 만들고 식별자 mapseg로 단편을 지정했습니다. 불행히도 Google을 통해 찾을 수있는 모든 것을 시도한 후에 올바른 액세서리 설명 선 버튼을 탭할 때 발생하는 segue를 얻을 수없고 이유가 없습니다. 응용 프로그램 자체는 세 개의 탭이있는 탭 응용 프로그램입니다. 두 번째 탭의보기는지도가 포함 된 탭입니다. 또한,이 작업이이 작업과 관련 될 수 있는지 여부는 알 수 없지만 전환하려고하는보기가 내비게이션 컨트롤러에 포함되어 있습니다. 다음은 전환하려는 관점에 대한 코드입니다.지도 주석에서 오른쪽 액세서리 콜 아웃 버튼을 탭하여 뷰를 전환하는 방법을 신속하게 처리합니다.
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