MapView在注释上显示不匹配的数据?

时间:2013-04-22 11:40:09

标签: xcode ios4 mkmapview

我是iPhone编程的新手,我正在练习MKMapView。但它显示的是未经授权的数据。 我有两个ViewControllers。在第一个ViewController上,我们有一个按钮,下面写的编码: -   有两个数组的数据如下所示: -   的 DetailArray: -  inNetwork = true;

    resName = taverna1;  
    statusColor = "#FF0000";
    statusString = "30 MIN";
    true = hasPromo;
},
    {
    false = hasPromo;
    inNetwork = true;
    resName = bungalow;
    statusColor = 00FF00;
    statusString = "NO WAIT";
},
    {
    inNetwork = true;
    resName = "casa_nostra";
    statusColor = 00FF00;
    statusString = "NO WAIT";
    true = hasPromo;
},
    {
    inNetwork = true;
    resName = karebu;
    statusColor = 00FF00;
    statusString = "NO WAIT";
    true = hasPromo;
}




**Annotation Array**

(
    "<MyAnnotViewController: 0x8457b60>",
    "<MyAnnotViewController: 0x845a040>",
    "<MyAnnotViewController: 0x84439f0>",
    "<MyAnnotViewController: 0x806f090>"
)

MyAnnoationViewcontroller是MKAnnotation的子类。它包含标题和坐标。

  SecondViewController *_SecondViewController =[[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
    _SecondViewController.DetailArray = detailArray;
    _SecondViewController.annotationArray = annotationArray;
     [self.navigationController pushViewController:_SecondViewController animated:YES];

在secondViewController上: -

MKMapView * MapView =[[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, 415)];
MapView.delegate =self;
MapView.showsUserLocation =NO;

[MapView addAnnotations:annotationArray];

[self.view addSubview:MapView];

在Delegate方法上,它在注释上显示非常不确定的结果.Chlorinates和title是期望的输出。但是第一个休息名称的颜色显示第二个餐厅的颜色,第二个显示任何其他颜色。请有人帮我解决这个问题。帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

你没有显示viewForAnnotation的代码,所以我只是想在黑暗中进行刺杀,并猜测你是根据数组的顺序设置你正在绘制的视图的颜色。不在传递给viewForAnnotation的注释对象上。您可以在StackOverflow上找到很多关于viewForAnnotation的问题。

P.S。你真的在使用iOS 4.0吗?那已经很老了。

相关问题