Hallo Leute!
Hab bis jetzt mit xcode4 entwickelt und hab nun natürlich vor mit xcode 5 die APPs upzudaten ... Dabei bin ich aber auf folgendes Problem gestoßen:
Meine MapView mit den custom Annotations gibt Fehler aus bzw. killt die APP, diese hat aber in xcode4 einwandfrei funktioniert! (Das ganze passiert sobald Annotations angezeigt werden sollen)
Vielleicht erbarmt sich kurz jemand und könnte drüberschaun, ich komm einfach nicht dahinter
MapViewController.m (das wichtigste daraus)
Alles anzeigen
AnnotationView.h
Alles anzeigen
AnnotationView.m
Alles anzeigen
Und als Ausgabe erhalte ich:
Alles anzeigen
Ich bin für jede Hilfe dankbar!!!
Beste Grüße
Gerhard
Hab bis jetzt mit xcode4 entwickelt und hab nun natürlich vor mit xcode 5 die APPs upzudaten ... Dabei bin ich aber auf folgendes Problem gestoßen:
Meine MapView mit den custom Annotations gibt Fehler aus bzw. killt die APP, diese hat aber in xcode4 einwandfrei funktioniert! (Das ganze passiert sobald Annotations angezeigt werden sollen)
Vielleicht erbarmt sich kurz jemand und könnte drüberschaun, ich komm einfach nicht dahinter
MapViewController.m (das wichtigste daraus)
Quellcode
- - (void)updateAnnotations
- {
- if (_myLongitude != nil) {
- pinExists = NO;
- for (NSMutableDictionary *annotations in _pois)
- {
- CLLocationCoordinate2D location;
- location.latitude = [annotations[@"POI_LAT"] doubleValue];
- location.longitude = [annotations[@"POI_LONG"] doubleValue];
- float myLatitude = [_myLatitude floatValue];
- float myLongitude = [_myLongitude floatValue];
- CLLocation *location1 = [[CLLocation alloc] initWithLatitude:myLatitude longitude:myLongitude];
- CLLocation *location2 = [[CLLocation alloc] initWithLatitude:location.latitude longitude:location.longitude];
- if ([location1 distanceFromLocation:location2]/1000 < 5) {
- pinsInRadius = YES;
- CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(location.latitude, location.longitude);
- AnnotationView *annotation = [[AnnotationView alloc] initWithCoordinate:coords addressDictionary:nil] ;
- annotation.title = [annotations objectForKey:@"POI_NAME"];
- annotation.image = [annotations objectForKey:@"POI_ICON"];
- annotation.PoiID = [annotations objectForKey:@"POI_ID"];
- for (AnnotationView *existAnns in self.mapView.annotations) {
- if ([existAnns.title isEqualToString:[annotations objectForKey:@"POI_NAME"]]) {
- pinExists = YES;
- }
- }
- if (pinExists == NO) {
- [self.mapView addAnnotation:annotation];
- }
- }
- }
- if (_pois != NULL) {
- if (pinsInRadius == YES) {
- _noPoisLabel.hidden = YES;
- } else if (pinsInRadius == NO){
- _loadingView.hidden = YES;
- _noPoisLabel.hidden = NO;
- }
- }
- }
- }
- - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
- {
- if ([annotation isKindOfClass:[MKUserLocation class]])
- return nil;
- MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
- if (!pinView)
- {
- pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"];
- pinView.canShowCallout=YES;
- pinView.annotation = annotation;
- pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
- AnnotationView *myAnn = (AnnotationView *)annotation;
- pinView.image = [UIImage imageNamed:myAnn.image];
- _loadingView.hidden = YES;
- }
- else
- pinView.annotation = annotation;
- return pinView;
- }
- -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
- {
- AnnotationView *annotapped = (AnnotationView *)view.annotation;
- _aktuellPoiId = annotapped.PoiID;
- [self.mapView setShowsUserLocation:NO];
- [self performSegueWithIdentifier:@"fromMapToDetail" sender:self];
- if(_timer)
- {
- [_timer invalidate];
- _timer = nil;
- }
- }
AnnotationView.h
Quellcode
- #import <MapKit/MapKit.h>
- @interface AnnotationView : MKPlacemark
- @property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate1;
- @property (nonatomic, strong) NSString *title;
- @property (nonatomic, strong) NSString *subtitle;
- @property (nonatomic, retain) NSString *image;
- @property (nonatomic, strong) NSString *PoiID;
- @property (nonatomic, weak) NSString *entfernung;
- @end
AnnotationView.m
Quellcode
- #import "AnnotationView.h"
- @implementation AnnotationView
- - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate2 addressDictionary:(NSDictionary *)addressDictionary
- {
- if ((self = [super initWithCoordinate:coordinate2 addressDictionary:addressDictionary]))
- {
- self.coordinate1 = coordinate2;
- }
- return self;
- }
- @end
Und als Ausgabe erhalte ich:
Quellcode
- 2013-09-18 18:39:14.067 MyApp[895:a0b] -[AnnotationView setTitle:]: unrecognized selector sent to instance 0xce80a20
- 2013-09-18 18:39:14.081 MyApp[895:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AnnotationView setTitle:]: unrecognized selector sent to instance 0xce80a20'
- *** First throw call stack:
- (
- 0 CoreFoundation 0x02d386f4 __exceptionPreprocess + 180
- 1 libobjc.A.dylib 0x01a8f8b6 objc_exception_throw + 44
- 2 CoreFoundation 0x02dd5983 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
- 3 CoreFoundation 0x02d28a1b ___forwarding___ + 1019
- 4 CoreFoundation 0x02d285fe _CF_forwarding_prep_0 + 14
- 5 Steirer Guide 3D 0x0000e073 -[MapViewController updateAnnotations] + 1283
- 6 Foundation 0x014b9db7 __NSFireTimer + 97
- 7 CoreFoundation 0x02cf6d06 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
- 8 CoreFoundation 0x02cf66ed __CFRunLoopDoTimer + 1181
- 9 CoreFoundation 0x02cde758 __CFRunLoopRun + 1816
- 10 CoreFoundation 0x02cddbf3 CFRunLoopRunSpecific + 467
- 11 CoreFoundation 0x02cdda0b CFRunLoopRunInMode + 123
- 12 GraphicsServices 0x02f92a27 GSEventRunModal + 192
- 13 GraphicsServices 0x02f9284e GSEventRun + 104
- 14 UIKit 0x005faf0b UIApplicationMain + 1225
- 15 Steirer Guide 3D 0x00008c5d main + 141
- 16 libdyld.dylib 0x065bb725 start + 0
- )
- libc++abi.dylib: terminating with uncaught exception of type NSException
- (lldb)
Ich bin für jede Hilfe dankbar!!!
Beste Grüße
Gerhard