Ios 引脚阵列,颜色不变

Ios 引脚阵列,颜色不变,ios,objective-c,arrays,annotations,mapkit,Ios,Objective C,Arrays,Annotations,Mapkit,我正在尝试为这两个属于不同类别的点动态设置pin颜色,但是它们在我的地图上没有显示不同的颜色。在数组底部的for循环中,您是否看到任何问题 #define UNIVERSITY_LATITUDE 35.22836; #define UNIVERSITY_LONGITUDE 126.84784; #define HOTEL_LATITUDE 34.55; #define HOTEL_LONGITUDE 127.36; @implementation MapKitViewController

我正在尝试为这两个属于不同类别的点动态设置pin颜色,但是它们在我的地图上没有显示不同的颜色。在数组底部的for循环中,您是否看到任何问题

#define UNIVERSITY_LATITUDE 35.22836;
#define UNIVERSITY_LONGITUDE 126.84784;
#define HOTEL_LATITUDE 34.55;
#define HOTEL_LONGITUDE 127.36;


@implementation MapKitViewController


//Synthesize the getters and setters of the map view
@synthesize mapView;



- (void)viewDidLoad
{
    [super viewDidLoad];

    NSMutableArray *annotations = [[NSMutableArray alloc] init];
    CLLocationCoordinate2D location;

   //used to test Annotations of map, will be replaced by for loop to insert new points
    PhotoPoint *photoAnn;
    photoAnn = [[PhotoPoint alloc] init];
    location.latitude =UNIVERSITY_LATITUDE;
    location.longitude = UNIVERSITY_LONGITUDE;
    photoAnn.coordinate = location;
    [photoAnn setTitle:@"GIST"];
    [photoAnn setSubtitle:@"University"];
    [photoAnn setAnnotationType:@"Photo"];
    [annotations addObject:photoAnn];

    CommercialPoint *commAnn;
    commAnn = [[CommercialPoint alloc] init];
    location.latitude =HOTEL_LATITUDE;
    location.longitude = HOTEL_LONGITUDE;
    commAnn.coordinate = location;
    [commAnn setTitle:@"Hotel"];
    [commAnn setSubtitle:@"Hotel Center"];
    [commAnn setAnnotationType:@"Commercial"];
    [annotations addObject:commAnn];

    for (id eachObject in annotations){
        if ([eachObject isKindOfClass:[PhotoPoint class]])
        {
            photoAnn.pinColor = MKPinAnnotationColorGreen;
        }
        if ([eachObject isKindOfClass:[CommercialPoint class]])
        {
            commAnn.pinColor = MKPinAnnotationColorPurple;
        }

    //send the delgate messages to the mapview
    mapView.delegate = self;
    [self.mapView addAnnotations:annotations];

for循环将在哪里结束?for(注释中的id eachObject),这是否意味着for循环在遍历数组中的所有对象时结束?@user3036511:在发布的代码中,它没有显示
for
循环的结束
}
。所以不清楚循环中是什么代码。无论如何,pinColor最终需要在
viewForAnnotation
delegate方法中设置。如果您已经实现了该方法,请编辑您的问题并添加该代码。