Ich versuche, Apple Maps innerhalb der Map zu öffnen, die ich erstellt habe, und dabei bekomme ich eine Fehlermeldung, dass "unerkannter Selektor an Instanz senden ". Ich verwende Lichtbogen, also sollte es kein Gedächtnismanagementproblem geben. Hier ist der Code, den ich in ViewDidLoad geschrieben habe. Ich habe einen Knopf und hat einen Selektor, um es ..Unbekannter Selektor wird an Instanz gesendet, während versucht wird, Apple Maps App in meiner App zu öffnen
UIButton *appleMapsButton = [[UIButton alloc] init];
appleMapsButton.frame = CGRectMake(100, 100, 200, 200);
appleMapsButton.backgroundColor = [UIColor redColor];
[appleMapsButton addTarget:self action:@selector(appleMapsClicked:) forControlEvents:UIControlEventTouchUpInside];
[mapView addSubview:appleMapsButton];
Hier ist die Aktionsmethode:
-(void)appleMapsClicked{
CLLocationCoordinate2D endingCoord = CLLocationCoordinate2DMake(lat, lng);
MKPlacemark *endLocation = [[MKPlacemark alloc] initWithCoordinate:endingCoord addressDictionary:nil];
MKMapItem *endingItem = [[MKMapItem alloc] initWithPlacemark:endLocation];
NSMutableDictionary *launchOptions = [[NSMutableDictionary alloc] init];
[launchOptions setObject:MKLaunchOptionsDirectionsModeDriving forKey:MKLaunchOptionsDirectionsModeKey];
[endingItem openInMapsWithLaunchOptions:launchOptions];
}
Hier ist der Fehler, den ich im Debugger Bereich bin immer:
- [ MapViewController appleMapsClicked:]: nicht erkannter Selektor an Instanz 0x176564d0 gesendet 2016-04-15 16: 10: 39.394 Restaurant [1081: 220822] *** Beenden der App aufgrund der nicht abgefangenen Ausnahme 'NSInvalidArgumentException', Grund: '- [MapViewController appleMapsClicked:] : unerkannter Selektor gesendet zum Beispiel 0x176564d0'