0

我是 iPhone 编程的新手,我正在练习 MKMapView。但它显示的是未占用的数据。我有两个 ViewController。在第一个 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 方法上,它在注释上显示出非常不确定的结果。氯化物和标题是所需的输出。但是第一个休息名称的颜色显示第二个餐厅的颜色,第二个显示任何其他颜色。请任何人帮助我摆脱这个问题。帮助将不胜感激。

4

1 回答 1

1

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

PS你真的在使用iOS 4.0吗?那是相当老了。

于 2013-04-22T21:27:29.933 回答