【发布时间】:2011-11-02 13:44:08
【问题描述】:
我使用 MKMapView。
mapView.showsUserLocation = YES;
我希望在应用找到用户位置时收到信号。
【问题讨论】:
我使用 MKMapView。
mapView.showsUserLocation = YES;
我希望在应用找到用户位置时收到信号。
【问题讨论】:
您可以在 mapview 委托的 mapView:didUpdateUserLocation: 方法中处理该事件 - 每次更新用户位置时都会调用它
【讨论】:
简单。
实现MKMapViewDelegate方法-mapView:didUpdateUserLocation:。
【讨论】:
为此,您必须实现委托方法:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
并将您的班级设置为您的 mapView 代表:
self.mapView.delegate = self;
如果您愿意,也可以在 IB 中这样做。
您的课程必须引用 MKMapViewDelegate 协议:
@interface YourClass : InheritanceObject <MKMapViewDelegate> {
MKMapView* mapView;
}
@property(nonatomic, retain) IBOutlet MKMapView* mapView; // IBOutlet if you create the mapView into IB
【讨论】: