【发布时间】:2012-07-27 22:17:20
【问题描述】:
我是 Objective C 的新手,但学得很快。我的项目非常完整,我已经实现了类,而不是委托等。
我正在使用 MKMapView 在地图上显示内容。我还需要用户点击会返回一些信息的 Pin 图,但我确实希望 MKViewMap 在发送信息之前做出一些估计。
因此,我对 MKMapView 进行了子类化,并且正在使用此类进行显示。但我没有接到代表的电话。当我以标准方式使用 MKViewMap 时,它可以正常工作。这是一些代码。子类有一个委托协议,这很好用
// .h 文件
#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 文件
#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");
}
后者永远不会被调用。有什么想法吗?
【问题讨论】:
-
我找到了解决方案。我不得不替换 self.delegate=self;与 super.delegate=self;还是谢谢
标签: delegates mkmapview subclass mkmapviewdelegate