我想知道如何相对于应用程序窗口获取集合视图中单元格的相对位置?我看到了一些关于swift和表格的示例,但是找不到Xamarin.iOS的示例
答案 0 :(得分:1)
翻译此thread中的解决方案:
public class collectionViewDelegate : UICollectionViewDelegate {
UIView view;
public collectionViewDelegate(UIView v)
{
//get the parent v when create collectionViewDelegate instance
this.view = v;
}
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
{
UICollectionViewCell cell = (UICollectionViewCell)collectionView.DequeueReusableCell("CollectionViewCell",indexPath);
CGRect frame = new CGRect(0,0,cell.Frame.Size.Width,cell.Frame.Size.Height);
frame.Location = collectionView.ConvertPointToView(cell.Frame.Location, this.view);
}
}