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现在来测试它。 –
谢谢,这似乎工作.. :) –