Reputation: 1
I am quite new in Objective C, but learning fast. My project is quite complete and I have implemented as well classes than delegates etc etc.
I am using an MKMapView to display things on a map. I also need the user to click on Pins which will give back some informations, but I do want that the MKViewMap makes some estimations before sending info.
As such I have subclassed MKMapView, and I am using this class to display. But I don't get the delegates called. It worked normally when I was using MKViewMap in a standard way. Here is some code. The subclass has a delegate protocol, and this works perfectly
// .h file
#import < MapKit/MapKit.h >
@protocol MyMapViewDelegate < NSObject >
@required
- (void) ReturnAddressToHail:(NSString*) FullAddresse andNumber:(NSString*) FullNumber;
- (void) ReturnSelectedDriverHash:(NSString*) DriverHash;
@end
@interface MyMapViewClass : MKMapView < MKMapViewDelegate >
{
id < MyMapViewDelegate > delegate;
CLLocationCoordinate2D mapCenter;
NSDictionary *Info;
CLLocation * ClientNewLocation;
}
@property (retain) id delegate;
// .m file
#import "MyMapViewClass.h"
#import "NSObject+MapAnnotationHelper.h"
@implementation MyMapViewClass
@synthesize geoCoder;
@synthesize delegate;
self.delegate = self;
-(void) mapView:(MKMapView *) mapView regionDidChangeAnimated:(BOOL)animated
{
(void) self.updateAddress;
NSLog(@"regionchange delegate");
}
The latter is never called. Any ideas?
Upvotes: 0
Views: 394
Reputation: 113747
I'm sure you have your reasons, but the docs state that you shouldn't subclass MKMapView
, and instead use the delegate to change its behaviour. There may be an easier way to do whatever you're doing.
Although you should not subclass the MKMapView class itself, you can get information about the map view’s behavior by providing a delegate object.
Upvotes: 2