我爲iOS創建Xamarin.Forms.Maps地圖。Xamarin表格地圖:Pin更改/替換後停止工作
我加一些針
我點擊處理程序添加到引腳
這些都做工精細
現在,用戶拖動地圖和火我ondrag當處理器
然後我想要刷新引腳以反映新的視圖區域 這也適用 - 除了現在的t上的Clicked事件他的針腳被忽略。顯示信息框,但當單擊信息框時,處理程序本身不會被調用。這在第一次設置時起作用,但在引腳改變之後不起作用。
我試圖拖就創造新的引腳:
map.Pins.Clear();
foreach (Place p in PlaceList){
Pin newPin = new Pin();
pin.Label = p.PlaceName;
pin.Clicked += DoPinClick;
}
,然後我試着拖動重用現有引腳:
Pin pin;
for (int i = 0; i < PlaceList.Count; i++) {
if (i > 9)
// max of 10 pins
break;
Place p = PlaceList [i];
if (i >= map.Pins.Count - 1) {
// a new pin to be created and added to the map pins
pin = new Pin();
pin.Clicked += DoPinClick;
pin.Label = p.PlaceName;
map.Pins.Add (pin);
} else {
// there was already a pin in that slot, get it and reuse it
pin = map.Pins [i];
pin.Label = p.PlaceName;
}
pin.Position = p.Position;
// copy the pin into the slot it occupies already
map.Pins [i] = pin;
}
但是我按照事件處理兩者的做法只能等到我改變引腳。
它可能並不重要,但你有沒有嘗試刪除該事件處理程序清除現有列表之前? –
我沒有,但我只是試過,沒有區別。 – WillG