Search Results

Search found 54 results on 3 pages for 'mkannotationview'.

Page 3/3 | < Previous Page | 1 2 3 

  • how do I get the program to Know which annotation is selected and be able to access properties of it

    - by kevin Mendoza
    So far my program can display a database of custom annotation views. Eventually I want my program to be able to display extra information after a button on the annotation bubble is clicked. Each element in the database has a unique entry Number, so I thought it would be a good idea to add this entry number as a property of the custom annotation. The problem I am having is that after the button is clicked and the program switches to a new view I am unable to retrieve the entry number of the annotation I selected. Below is the code that assigns the entry Number property to the annotation: for (id mine in mines) { workingCoordinate.latitude = [[mine latitudeInitial] doubleValue]; workingCoordinate.longitude = [[mine longitudeInitial] doubleValue]; iProspectAnnotation *tempMine = [[iProspectAnnotation alloc] initWithCoordinate:workingCoordinate]; [tempMine setTitle:[mine mineName]]; [tempMine setAnnotationEntryNumber:[mine entryNumber]]; } [mines dealloc]; When the button on an annotation is selected, this is the code that initializes the new view: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { mineInformationController *controller = [[mineInformationController alloc] initWithNibName:@"mineInformationController" bundle:nil]; controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:controller animated:YES]; [controller release]; } and lastly is my attempt at retrieving the entryNumber property from the new view so that I can compare it to the mines database and retrieve more information on the array element. iProspectFresno_LiteAppDelegate *appDelegate = (iProspectFresno_LiteAppDelegate *)[[UIApplication sharedApplication] delegate]; NSMutableArray* mines = [[NSMutableArray alloc] initWithArray:(NSMutableArray *)appDelegate.mines]; for(id mine in mines) { if ([[mine entryNumber] isEqualToNumber: /*the entry Number of the selected annotation*/]) { /* display the information in the mine object */ } } So how do I access this entry number property in this new view controller?

    Read the article

  • annotationView didChangeDragState being fired multiple times

    - by RodH257
    I've got a draggable annotation in IOS4 mapkit, and I'm trying to call an event when the annotation is dragged to a new position. my code currently looks like: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { CLLocationCoordinate2D droppedAt = annotationView.annotation.coordinate; NSLog(@"dropped at %f,%f", droppedAt.latitude, droppedAt.longitude); //update the annotation //see if its an information annotation if ([annotationView.annotation isKindOfClass:[InfoAnnotation class]]) { NSLog(@"Info annotation updating.."); InfoAnnotation* userAnnotation = ((InfoAnnotation *)annotationView.annotation); [userAnnotation updateLocationWithServerForConvoy: self.title]; } } } the code simply logs the update and then tells the annotation to send its update to my server, which is a custom method. This method seems to be getting fired multiple times, see the log here: 2011-06-15 01:12:39.347 Convoy[1699:207] dropped at 37.340206,-122.027550 2011-06-15 01:12:39.347 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:39.658 Convoy[1699:207] dropped at 37.340206,-122.027550 2011-06-15 01:12:39.659 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:39.957 Convoy[1699:207] dropped at 37.340206,-122.027550 2011-06-15 01:12:39.958 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:43.415 Convoy[1699:207] dropped at 37.339251,-122.026691 2011-06-15 01:12:43.416 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:43.713 Convoy[1699:207] dropped at 37.339251,-122.026691 2011-06-15 01:12:43.713 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:44.006 Convoy[1699:207] dropped at 37.339251,-122.026691 2011-06-15 01:12:44.006 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:44.297 Convoy[1699:207] dropped at 37.339251,-122.026691 2011-06-15 01:12:44.297 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:54.825 Convoy[1699:207] dropped at 37.337135,-122.025833 2011-06-15 01:12:54.825 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:55.150 Convoy[1699:207] dropped at 37.337135,-122.025833 2011-06-15 01:12:55.150 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:55.475 Convoy[1699:207] dropped at 37.337135,-122.025833 2011-06-15 01:12:55.476 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:55.771 Convoy[1699:207] dropped at 37.337135,-122.025833 2011-06-15 01:12:55.772 Convoy[1699:207] Info annotation updating.. 2011-06-15 01:12:56.070 Convoy[1699:207] dropped at 37.337135,-122.025833 2011-06-15 01:12:56.070 Convoy[1699:207] Info annotation updating.. Each time I drag it (ie in the gaps) it seems to add 1 to the amount of times it's called. Can anyone give me any idea what may be causing this?

    Read the article

  • Custom Annotation not showing all

    - by funatsg
    Okay, i have a number of pins on the mapkit. These pins showing different types of attractions. (E.g Parks, Farms and etc) I want to add custom images for these different types of pin. Parks have a park image and vice versa. However, when i added in, not all the images are showing successfully. For example, in parks, it should have 5 pins, but the image only came up in 2 pins, whereas other 3 is in default red pins. But if i used colours to differentiate them. For example, [pinsetPinColor:MKPinAnnotationColorGreen]; It works! Anyone knows what is the problem? Relevant codes below. Tell me if you need more. thanks! - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ if ([annotation isKindOfClass:MKUserLocation.class]) { //user location view is being requested, //return nil so it uses the default which is a blue dot... return nil; } //NSLog(@"View for Annotation is called"); MKPinAnnotationView *pin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil]; pin.userInteractionEnabled=TRUE; MapEvent* event = (MapEvent*)annotation; NSLog(@"thetype: %@", event.thetype); if ([event.thetype isEqualToString:@"adv"]) { //[pin setPinColor:MKPinAnnotationColorGreen]; pin.image = [UIImage imageNamed:@"padv.png"]; } else if ([event.thetype isEqualToString:@"muse"]){ //[pin setPinColor:MKPinAnnotationColorPurple]; pin.image = [UIImage imageNamed:@"pmuse.png"]; } else if ([event.thetype isEqualToString:@"nightlife"]){ pin.image = [UIImage imageNamed:@"pnight.png"]; } else if ([event.thetype isEqualToString:@"parks"]){ pin.image = [UIImage imageNamed:@"ppark.png"]; } else if ([event.thetype isEqualToString:@"farms"]){ pin.image = [UIImage imageNamed:@"pfarm.png"]; } else { [pin setPinColor:MKPinAnnotationColorRed]; } pin.canShowCallout = YES; pin.animatesDrop = YES; UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(clickAnnotation:) forControlEvents:UIControlEventTouchUpInside]; [rightButton setTitle:event.uniqueID forState:UIControlStateNormal]; pin.rightCalloutAccessoryView = rightButton; return pin; }

    Read the article

  • Can't access annotation property of subclassed uibutton - editted

    - by Tzur Gazit
    Below is my original question. I kept investigating and found out that the type of the button I allocate is of type UIButton instead of the subclassed type CustomButton. the capture below is the allocation of the button and connection to target. I break immediately after the allocation and check the button type (po rightButton at the debugger console). It's turned out tht the type is UIButton instead of CustomButton. CustomButton* rightButton = [CustomButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; I have a mapView to which I add annotations. The pin's callout have a button (rightCalloutAccessoryView). In order to be able to display various information when the button is pushed, i've subclassed uibutton and added a class called "Annotation". @interface CustomButton : UIButton { NSIndexPath *indexPath; Annotation *mAnnotation; } @property (nonatomic, retain) NSIndexPath *indexPath; @property (nonatomic, copy) Annotation *mAnnotation; - (id) setAnnotation2:(Annotation *)annotation; @end Here is "Annotation": @interface Annotation : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString *mPhotoID; NSString *mPhotoUrl; NSString *mPhotoName; NSString *mOwner; NSString *mAddress; } @property (nonatomic, assign) CLLocationCoordinate2D coordinate; @property (nonatomic, copy) NSString *mPhotoID; @property (nonatomic, copy) NSString *mPhotoUrl; @property (nonatomic, copy) NSString *mPhotoName; @property (nonatomic, copy) NSString *mOwner; @property (nonatomic, copy) NSString *mAddress; - (id) initWithCoordinates:(CLLocationCoordinate2D)coordinate; - (id) setPhotoId:(NSString *)id url:(NSString *)url owner:(NSString *)owner address:(NSString *)address andName:(NSString *)name; @end I want to set the annotation property of the uibutton at - (MKAnnotationView *)mapView:(MKMapView *)pMapView viewForAnnotation:(id )annotation, in order to refer to it at the button push handler (-(IBAction) showDetails:(id)sender). The problem is that I can't set the annotation property of the button. I get the following message at run time: 2010-04-27 08:15:11.781 HotLocations[487:207] *** -[UIButton setMAnnotation:]: unrecognized selector sent to instance 0x5063400 2010-04-27 08:15:11.781 HotLocations[487:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIButton setMAnnotation:]: unrecognized selector sent to instance 0x5063400' 2010-04-27 08:15:11.781 HotLocations[487:207] Stack: ( 32080987, 2472563977, 32462907, 32032374, 31884994, 55885, 30695992, 30679095, 30662137, 30514190, 30553882, 30481385, 30479684, 30496027, 30588515, 63333386, 31865536, 31861832, 40171029, 40171226, 2846639 ) I appreciate the help. Tzur.

    Read the article

< Previous Page | 1 2 3