mkannotationview

MapKit iOS 9 detailCalloutAccessoryView usage

徘徊边缘 提交于 2019-12-17 15:44:07
问题 After watching WWDC video 206 I assumed this would be a trivial task of adding the detail callout view to a mapView annotation view. So, I assume Im doing something wrong. With my pin view set up func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { let view:MKAnnotationView! if let dequed = routeMapView.dequeueReusableAnnotationViewWithIdentifier("pin") { view = dequed } else { view = MKPinAnnotationView(annotation: annotation, reuseIdentifier:

How to create rounded image with border and shadow as MKAnnotationView in Swift?

 ̄綄美尐妖づ 提交于 2019-12-14 03:54:00
问题 I'd like to create MKAnnotationView that looks like the one below. The code I already have: func maskRoundedImage(image: UIImage, radius: Float) -> UIImage { let imageView: UIImageView = UIImageView(image: image) var layer: CALayer = CALayer() layer = imageView.layer layer.masksToBounds = true layer.cornerRadius = CGFloat(radius) layer.borderWidth = 4.0 layer.borderColor = UIColor.whiteColor().CGColor UIGraphicsBeginImageContext(imageView.bounds.size) layer.renderInContext

Only one (custom) annotation rotating from an array of other annotations

拟墨画扇 提交于 2019-12-14 01:02:35
问题 I am almost towards the last phase of my app, which shows a live map of buses. So, basically, I have a timer which gets the latitude and longitude of a bus periodically from a xml sheet which provides real-time locations of the buses. I was able to setup the xml parser, animate the buses' movement and setup a custom (arrow) image for the buses. However, the problem is, from an array of multiple buses, I can only get a single bus to rotate . Looking at the xml data, it's always the first bus

Creating a dynamic MKAnnotationView in Swift

只愿长相守 提交于 2019-12-13 19:01:52
问题 Currently, I know how to create a MKAnnotationView with a static pin, an image that's added. Does anyone know, or have any resources, on how to create a pin that would change colors or have a number displayed inside of it that would change depending on information about the business? For instance, I would like to have a pin be red when the business is closed, and green when the business is open. Maybe even a dollar signs inside of the pin to tell the user how expensive it is. EDIT I have

Change the image's origin of map annotation view?

谁都会走 提交于 2019-12-13 12:01:55
问题 The regular annotation pin's origin is in the middle of the bottom so, the pin always point to the same place. But when I add my custom image, its origin is the center of the image, so every zoom in or out, the bottom of my image point to a different place. Here my pin is supposed to point to the center of paris BUT but when I zoom in, the bottom of my pin isn't pointing to the center of Paris. I'm trying with the CGRect.origin but didn't get anything useful. Here is my code: -

Show Annotation Title and SubTitle in Custom MKPinAnnotationView

☆樱花仙子☆ 提交于 2019-12-13 05:52:19
问题 I am using MKPinAnnotationView inside my App. I am setting MapView object as delegate, and using this code for customising my AnnotationView func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { //return nil so map view draws "blue dot" for standard user location return nil } let reuseId = "pin" var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView if pinView == nil {

Subclassing MKAnnotationView with use of auto layout

这一生的挚爱 提交于 2019-12-13 01:30:06
问题 I like the new auto layout functionality in iOS 6 but I've run into a bit of trouble when using it in combination with my MKAnnotationView subclass. I've disabled the autoresizing mask translation in the initialization method. self.translatesAutoresizingMaskIntoConstraints = NO; But the app throws an NSInternalInconsistencyException when I load the MKMapView that uses an annotation of my subclass. *** Assertion failure in -[ENMapAnnotationView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim

Custom MKAnnotationView touch zone is ridiculously narrow

安稳与你 提交于 2019-12-13 00:23:38
问题 My custom MKAnnotationView subclass do not set it's image property. Instead, it handle some subviews to be displayed. I implement public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) in my delegate to detect annotation touch. Because touch zone is by default calculated with the image property, my annotation view touch zone is about 1px large. This is ridiculous. This is how I create it: init(annotation: JZStreamAnnotation) { self.imageView = UIImageView.init(image: <an

Sometimes strange artifact appears when [mapView selectAnnotation];

不问归期 提交于 2019-12-12 17:22:37
问题 [_mapView selectAnnotation:sannotation animated:YES]; It appears not always, so I don't understand what's the reason for it. How to fix it? 回答1: Before selecting any annotation deselect all annotations on mapView. for (id<MKAnnotation> annotation in mapView.annotations) [mymap deselectAnnotation:annotation animated:NO]; I had same issue when along with default callout, I had implemented custom callouts. Though it is not a perfect solution it served the purpose. 来源: https://stackoverflow.com

Rotate annotation image on MKMapView

时光总嘲笑我的痴心妄想 提交于 2019-12-12 14:26:21
问题 I am trying to rotate an image that is added to MKMapView as an annotation. This is the code: -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation { if (! [annotation isKindOfClass:[IGAMapAnnotation class]]) { //return default view if annotation is NOT of type IGAMapAnnotation... return nil; } MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"IGAMapAnnotation"]; if (annotationView == nil) { annotationView = [