Swift performSegue going to Xcode

余生长醉 提交于 2019-11-26 21:59:43

问题


I am trying to perform a Segue between two UI Views I have correctly typed the identifier for the segue as can be seen Here

This is my function, with the same identifier "no" but when the button is clicked in the simulator it simply shows This (It looks like it is showing the stack in bottom left?)

 func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
    if control == view.rightCalloutAccessoryView {
         performSegue(withIdentifier: "no", sender:self)
    }
}

I have attached my full code incase further analysis is needed. Thanks for your help.

View Controller: import UIKit import MapKit import CoreLocation

class ViewController: UIViewController, MKMapViewDelegate,CLLocationManagerDelegate {

@IBOutlet weak var MapView: MKMapView!
let manager = CLLocationManager()

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    //let location = locations[0]


    //let span:MKCoordinateSpan = MKCoordinateSpanMake(0.02, 0.02)

    //let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)


}
override func viewDidLoad() {
    super.viewDidLoad()

    // tracking user's location
    manager.delegate = self
    manager.desiredAccuracy = kCLLocationAccuracyBest
    manager.requestWhenInUseAuthorization()
    manager.startUpdatingLocation()

    // Setting up Map
    let distanceSpan:CLLocationDegrees = 2000
    MapView.setRegion(MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(-39.0556253, 174.0752278), distanceSpan, distanceSpan), animated: true)
    MapView.showsUserLocation = true
    MapView.delegate = self

// artwork on map
    let windwandcoord: CLLocationCoordinate2D = CLLocationCoordinate2DMake(-39.055961,174.072288)
    let artworkPin = Artwork(title:"Wind Wand",locationName:"Majestic",discipline:"Statue",
                             coordinate:windwandcoord)
    MapView.addAnnotation(artworkPin)
}


func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
{
    if annotation is MKUserLocation {return nil}

    let reuseId = "pin"

    var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) as? MKPinAnnotationView
    if pinView == nil {
        pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        pinView!.canShowCallout = true
        pinView!.animatesDrop = true
        pinView!.calloutOffset = CGPoint(x: -5, y: 5)
        let calloutButton = UIButton(type: .detailDisclosure)
        pinView!.rightCalloutAccessoryView = calloutButton
        pinView!.sizeToFit()
    }
    else {
        pinView!.annotation = annotation
    }


    return pinView
}



func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
    if control == view.rightCalloutAccessoryView {
         performSegue(withIdentifier: "no", sender:self)
    }
}


}

Any help appreciated.


回答1:


See the solid blue bar in the gutter in your screen shot?

It is a breakpoint. When the path of execution reaches a breakpoint that is active (solid blue like this), we pause there. That is what a breakpoint is for.

If you don't want that to happen, drag the breakpoint out of the gutter.



来源:https://stackoverflow.com/questions/40499655/swift-performsegue-going-to-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!