2016-09-16 51 views
0

在我的出租车应用程序中,我创建了一个自定义的MKAnnotationView来显示驱动程序的估计位置。这很简单:与自定义MKAnnotationView不兼容的指针

#import <MapKit/MapKit.h> 

@interface EstimatedArrivalView : MKAnnotationView 

- (void)setText:(NSString *)min :(NSString *)time; 

@end 

然而,当我尝试执行我的ViewController下面的代码:

EstimatedArrivalView *av = [_fullScreenMapView viewForAnnotation:driverPoint]; 
[av setText:@"MIN" : [NSString stringWithFormat:@"%d", etaTimeCount]]; 

我得到以下警告:

Incompatible pointer types initializing 'EstimatedArrivalView *' with an expression of type 'MKAnnotationView * _Nullable' 

据我了解,我正在将EstimatedArrivalView初始化为一个MKAnnotationView。那么为什么警告呢?

回答

1

我觉得要解决这个错误,你应该尝试铸造MKAnnotationView因为像这样的EstimatedArrivalView:

EstimatedArrivalView *av = (EstimatedArrivalView *)[_fullScreenMapView viewForAnnotation:driverPoint];