0
我已閱讀許多教程那裏爲UICollectionView爲iOS和Xamarin.iOS 大家已經顯示出相同的樣品教程與一個圖像內UICollectionViewCellUICollectionView Xamarin.iOS,與按鈕個人細胞
希望的輸出
我做了什麼
問題
當我點擊簿按鈕,它觸發事件多次。奇怪的是,它並不一致,有時它會觸發一次一段時間的兩倍或一段時間的三倍或任何...
代碼段
List<MeetingRoom> data = new List<MeetingRoom>();
async public override void ViewDidLoad()
{
base.ViewDidLoad();
data = await DashboardServices.getMeetingRooms(DateTime.Now);
MeetingRoomCollection.WeakDataSource = this;
}
public nint GetItemsCount(UICollectionView collectionView, nint section)
{
var count = data.Count;
return count;
}
public UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
{
var cell = (MeetingRoomCell)collectionView.DequeueReusableCell("cell", indexPath);
cell.RoomName.Text = data[indexPath.Row].Room_Name;
cell.Status.Text = data[indexPath.Row].Availability;
cell.BookButton.Tag = indexPath.Row;
cell.BookButton.TouchUpInside += Cell_BookButton_TouchUpInside;
return cell;
}
void Cell_BookButton_TouchUpInside(object sender, EventArgs e)
{
var x = sender as UIButton;
Debug.WriteLine("index : {0}, status : {1}", (int)x.Tag, data[(int)x.Tag].Availability);
this.PerformSegue("segue_bookRoom", this);
}
請建議需要做什麼要解決這個問題,任何可用的教程參考將不勝感激。如果有Xamarin.iOS提示,那將會很好..
嘗試先取消訂閱該活動,然後訂閱以防止多個觸發器。告訴我它是否適用於發佈爲答案,我現在沒有Mac現在來測試它。 –
謝謝,這似乎工作.. :) –