0

好吧,有一个奇怪的问题,我设置为地图叠加层的折线显示得很好,除非我尝试访问 rendererForOverlay 方法中的枚举变量。

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKGeodesicPolyline class]]) //If I change MKGeodesicPolyline to my subclass it won't render the overlay.
{
    CustomLine *poly = (CustomLine *)overlay;

    MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:(CustomLine *)overlay];


    //[poly testFunction]; //This will also cause overlay to not show

    //If I uncomment this it will cause the overlay to not show
    /*
    if (*poly.linecheck == Clear)
    {
        NSLog(@"Overlay should be red");
        renderer.strokeColor = [NSColor greenColor];
    }
    if (*poly.linecheck == Bad)
    {
        NSLog(@"Overlay should be green");
        renderer.strokeColor = [NSColor redColor];
    }
    */
    renderer.strokeColor = [NSColor redColor];
    //NSLog(@"polyline.linecheck %u",*poly.linecheck); //if this is uncommented it will also break the overlay.
    renderer.lineWidth = 3.0;
    return renderer;
}

return nil;

这是我的自定义折线的标题。

#import <MapKit/MapKit.h>

enum linecheck
{
    Clear,
    Bad
};

@interface CustomLine : MKGeodesicPolyline
{

}

@property (readwrite) enum linecheck *linecheck;
4

0 回答 0