mkannotation

Swift: MKAnnotation long title text

天涯浪子 提交于 2019-12-10 21:14:19
问题 I have long MKannotationView title text. Is there an easy way to give Text in title proper size? reuseId = "Pin" var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId) pinView!.image = UIImage(named:"pin") pinView?.canShowCallout = true pinView?.annotation let button : UIButton = UIButton(type: UIButtonType.DetailDisclosure) button.setImage(UIImage(named: "pin_arrow")?.imageWithRenderingMode

How can the MKUserLocation be programmatically selected?

纵饮孤独 提交于 2019-12-10 19:37:46
问题 Titles and subtitles can be added to the user location that iOS shows using MKUserLocation. When the user taps on the location, these will show in a bubble above the location. The thought bubbles for other annotations can be shown by selecting the annotation with setSelected:animated: from MKAnnotationView. Unfortunately, MKUserLocation does not descend from MKAnnotationView. How can I programmatically select the user location so the annotation appears over the user location without the user

Expression is not assignable, coordinate attribute from MKAnnotation class delegate

落爺英雄遲暮 提交于 2019-12-10 16:11:27
问题 I did this schema in order to explain better what is my troubles. So, what can I do to fix it? Thank you =) 回答1: The CLLocationCoordinate2D is a struct , i.e. a value type. It is passed around by value, which is another way of saying "copying". If you assign its fields (e.g. longitude) all that would do is modifying a copy ; the original coordinate inside your Annotation would remain intact. That is why the property is not assignable. To fix this, you should add separate properties for

MapKit Annotations not showing up on map

[亡魂溺海] 提交于 2019-12-10 15:17:51
问题 I'm having trouble getting the MKAnnotationViews show up on the map in MapKit. I'm using iOS 7, and have now searched the forums and the web for many hours, trying different samples and setups. Below I have the most basic setup possible (I think) to make it work. The app contains a single ViewController with a toolbar with a button on top, and the rest is the MapView. The button triggers the method zoomToUser:(UIBarButtonItem*)sender. Right-clicking and checking my outlets and delegates seem

Custom MKAnnotation Image goes back to default when I attempt to drag

此生再无相见时 提交于 2019-12-10 03:36:38
问题 I've got a bunch of MKAnnotations that don't need dragging. I set this by [pin setDraggable:NO] . I'm having an issue when I touch the annotation and (accidentally) drag off an annotation, it instantly looses it's custom image and changes back to the default red pin. How do I prevent this from happening? 回答1: In the viewForAnnotation delegate method, make sure the view is created as an MKAnnotationView and not an MKPinAnnotationView (which is a subclass of MKAnnotationView that automatically

iOS MapKit Changing mapview maptype causes annotation image to change to pin?

百般思念 提交于 2019-12-10 02:25:01
问题 Any suggestions on what is wrong with the following would be appreciated. I am adding a custom image to an annotation using the following code. - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation isMemberOfClass:[MKUserLocation class]]) { return nil; } if ([annotation isMemberOfClass:[SpectatorPin class]]) { SpectatorPin *sp = (SpectatorPin *)annotation; MKAnnotationView *view = [self.mapView

How to create an NSMutableArray and assign a specific object to it?

て烟熏妆下的殇ゞ 提交于 2019-12-10 02:06:19
问题 I am just getting into Obj C, and I am looking to create an array of MKAnnotations. I have already created the MKAnnotation class called TruckLocation that contains the name, description, latitude, and longitude. Here is what I have so far for the array: NSMutableArray* trucksArray =[NSMutableArray arrayWithObjects: @[<#objects, ...#>] nil]; 回答1: Yore trying to combine 2 different syntaxes for similar but different things. You also don't seem to have any instances of your annotations. Create

Open Map Annotation from Selected Row in Table View

半世苍凉 提交于 2019-12-10 01:00:35
问题 I have a map view in one class with all of my annotations with titles and subtitles. There is a nav bar button that shows a list of all of those titles and subtitles. I'm wanting to be able to select a row in the table view and have it open the annotation with the same title in the map view. Any help? The only problem I have now is getting the annotation to show when the map view opens. I know I need to use selectAnnotation: animated: but I'm having trouble figuring out how to tell it to open

mkmapview MKUserLocation AnnotationView

不羁岁月 提交于 2019-12-09 19:20:54
问题 I'm trying to create custom annotationviews for the annotations on my map. I'm doing that by adapting the protocol MKMapViewDelegate and overwriting the function mapView:viewForAnnotation: . It all works, the only problem is that I also have showsUserLocation set to TRUE , which means that one "Annotation" I get in my mapView:viewForAnnotation: method is of the class MKUserLocation . I don't want the userlocation annotation to have my custom annotationview, I want that one to show the default

Change Pin Color when user tapped

旧城冷巷雨未停 提交于 2019-12-09 06:54:39
问题 I would change the color from red to green of an annotation when the user pin tapped addition to changing its title and subtitle. I am truly lost. I searched how to make a custom annotation pin, ok. I found the implementation of the method when the user touches the pin didSelectAnnotationView and it works when I tap the annotation NSLog(@"Tap") ; , but now I can not change the pin that was touched. Thank you very much everyone for your contributions. Ciao 回答1: To set the pin color, make use