mkannotation

how to add UITextField in MKAnnotationView Title

邮差的信 提交于 2019-12-11 19:59:52
问题 I try like this, but it isn't work. How can i do this ? MKAnnotationView *pointTest = [[MKAnnotationView alloc] init]; pointTest.annotation = point; pointTest.draggable= YES; UITextField *pointText = [[UITextField alloc] initWithFrame:CGRectMake(location.latitude, location.longitude, 100, 20)]; pointText.backgroundColor = [UIColor blackColor]; pointTest.rightCalloutAccessoryView = pointText; pointTest.canShowCallout = YES; [self.userMap addAnnotation:pointTest]; 回答1: First of all, you are

Determine which MKPinAnnotationView was selected?

霸气de小男生 提交于 2019-12-11 19:17:57
问题 I place some custom MKPinAnnotationView on the map, with different information about landmarks (name, description, image, accessory button). When a user click and open one of the pins, and then click the accessory button inside it, I want to know which of the pins the user have clicked so I can load a viewcontroller with more detailed information. I found these methods: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *

Swift obtain visible annotations/clusters shown in map

纵然是瞬间 提交于 2019-12-11 18:14:17
问题 I'm currently developing an app where I load user images as an annotation onto a map. Currently, I use an API to load images in viewForAnnotation for each image annotation and if the user has more than a few thousand photos, this image loading function is called every time and degrades performance significantly. Is there anyway I can obtain just the annotations which are shown on the map currently, i.e. only the annotations and clusters of annotations that are visible to the user? Apple's API

Why are my annotations not appearing in my map view?

南笙酒味 提交于 2019-12-11 18:08:54
问题 I have created a set of "IssueLocation"'s, a class which conforms to the MKAnnotation protocol. Why are my annotations (built from API JSON data) not appearing in my map view ? Here is the code behind it all: Class code: class IssueLocation: NSObject, MKAnnotation { var locationName: String var campusName: String var latitude: Double var longitude: Double var coordinate: CLLocationCoordinate2D init(locationName: String, campusName: String, latitude: Double, longitude: Double, coordinate:

if let doesn't unwrap optional value for MKAnnotation's title property

蹲街弑〆低调 提交于 2019-12-11 17:24:19
问题 I want to unwrap optional value with if-let statement. I need to get title of MKAnnotation. func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { if let title = view.annotation?.title { print(title) //Optional("Moscow") } } Why if-let doesn't work here? 回答1: The type of MKAnnotation.title is String?? , it's a nested Optional , so you need to optional bind it twice. func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { if let optionalTitle = view.annotation?

How to get the title and subtitle for a pin when we are implementing the MKAnnotation?

天涯浪子 提交于 2019-12-11 16:28:02
问题 I have implemented the MKAnnotation as below. I will put a lot of pins and the information for each of those pins are stored in an array. Each member of this array is an object whose properties will give the values for the title and subtitle of the pin. Each object corresponds to a pin. But how can I display these values for the pin when I click a pin?? @interface UserAnnotation : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString *title; NSString *subtitle; NSString *city;

ASIHttpRequest problems. “unrecognized selector sent to instance”

南楼画角 提交于 2019-12-11 15:29:50
问题 I am experiencing problems using ASIHttpRequst. This is the error I get: 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890' 2010-04-11 20:47:08.176 citybikesPlus[5885:207] Stack: ( 33936475, 2546353417, 34318395,

Save and Load MapAnnotation pins using NSMutableArray

会有一股神秘感。 提交于 2019-12-11 13:38:55
问题 I need help with my MapAnnotation codes. I want to save map pins so that the user can come back to the map and see the ones he/she has placed. However this code does not show the pins when the view loads. Code for adding and saving pins: - (void)addPinToMap:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; CGPoint touchPoint = [gestureRecognizer locationInView:self.mapView]; CLLocationCoordinate2D touchMapCoordinate = [self

Swift - Coordinate is unavailable: APIs deprecated as of iOS 7

僤鯓⒐⒋嵵緔 提交于 2019-12-11 12:48:08
问题 I'm trying to iterate through an array of annotations by getting by self.mapView.annotations . The issue I'm having is that i'm getting an error because Coordinate is unavailable: APIs deprecated as of iOS 7 and earlier are unavailable to Swift . Any ideas how I can fix this? I have a look at the iOS developer library but I couldn't find any way of getting the coordinate for each annotation. var zoomRect:MKMapRect = MKMapRectNull; for (index,annotation) in enumerate(self.mapView.annotations)

MKAnnotationView image changing issue

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 12:30:05
问题 I've got an MKMapView loaded with plenty of custom annotation (800 circa). When I drag on the map and I return to an annotation, it's image has changed with another one. For me it's seems like a cache issue. Pin before dragging Pin after dragging SuperClass header #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface MapAnnotation : NSObject <MKAnnotation> @property (nonatomic, copy) NSString *title; @property NSString * pinImageName; @property (nonatomic)