2015-11-23 38 views
0

OK, 我有酒吧的數組:設置第一註釋

var pubs = [Pub(coordinate: CLLocationCoordinate2D(latitude: 43.2282385, longitude: 76.855085)), 
    Pub(coordinate: CLLocationCoordinate2D(latitude: 43.2345965, longitude: 76.8907758)). 

,我添加註釋到我的地圖:

mapView.addAnnotations(pubs). 

然後我選擇第一個註釋是這樣的:

mapView.selectAnnotation(mapView.annotations.first!, animated: true) 

但現在它顯示第一個選定的註釋,然後顯示第二個。

問題: 如何在註釋中首先設置所需的註釋?

謝謝。

+0

你的「,但現在它顯示第一選擇的註解是什麼意思選擇它,然後第二個。「 ? – ogres

+0

我有tableView,哪裏有2個酒吧。當我第一次選擇時,它必須顯示第一個酒吧選擇和第二個酒吧未選中。當我選擇第二個時,它必須顯示第二個發佈者選擇,第一個發佈者未選中。 (對不起我的英語不好)。但是,當我點擊第一家酒吧時,有時會顯示第一家酒吧,有時是第二家酒吧。 – aaisataev

+0

當你做selectAnnotation時會發生什麼?它應該按照你想要的完成 – ogres

回答

0

Howe說@ogres:mapView可能重新安排Pubs的陣列,所以我不得不從TableView -s陣列mapView.selectAnnotation(tableView.annotations.first!, animated: true)