I want the balloon to stick to the pin like Apple's standard map
I use storyBoard for screen transition
Screen Transition Methods
func mapView (mapView:MKMapView, viewForAnnotation:MKAnnotation) ->MKAnnotationView? {
if announcement is MKUserLocation {
return nil
}
// Identifier
let myAnnotationIdentifier="myAnnotation"
// Request AnnotationView
var myAnnotationView: MKAnnotationView!=mapView.dequeueReusableAnnotationViewWithIdentifier (myAnnotationIdentifier)
// Setting the button to the right of the annotation
let button —UIButton = UIButton (type: UIButtonType.InfoLight)
if myAnnotationView == nil {
myAnnotationView = MKPinAnnotationView (annotation:annotation, reuseIdentifier: myAnnotationIdentifier)
// Attach a button to the right of the annotation
myAnnotationView.rightCalloutAccessoryView=button
myAnnotationView.canShowCallout=true
}
return myAnnotationView
}
funcmapView(mapView:MKMapView, announcementView:MKAnnotationView, calloutAccessoryControlTapped control:UIControl){
print("tapped")
self.performSegueWithIdentifier("detailController", sender:view)
}
It's like this."I would like to attach the button ""i"" to the right side of the pin, and pop over the detail screen appears by tapping the button."
StoryBoard has two views: Map view and Popover view.
"Here, I have to specify a balloon in the item ""anchor"", but how should I describe the pin in the map?"
Thank you for your cooperation.
Pins are generated dynamically while running the app, so it will be difficult to specify them as Anchors on the Storyboard.
This is the first time I've tried implementing Popover display on the Storyboard, but as you said, if I don't set Anchor, I get an error and the app build fails, so I don't think it's possible to specify Anchor alone by code.
This means that we have no choice but to stop setting Segue on the Storyboard and display Popover only with code.For more information on how to display Popover only by code, see the specific code in the UIPopoverPresentationController
document:
UIPoverPresentationController Class Reference
※ For some reason, the code appears only in the Objective-C version of the document.
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
573 Understanding How to Configure Google API Key
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
890 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
600 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.