访问枚举变量会导致MKPolyline子类无法呈现

时间:2013-12-03 05:09:19

标签: mapkit mkpolyline

好吧,有一个奇怪的问题,我的折线设置为我的地图的叠加显示正常,除非我尝试访问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;

0 个答案:

没有答案
相关问题