それぞれに 'color'文字列値を含む 'TagInstances'のリストがあります。私UICollectionViewでセルをスキップする方法/ GetCellメソッド、UICollectionViewからセルを返す方法
List<TagInstance> tags
私はtagCellsの初期化を断念したい場合:
イム "cellForItemAtIndexPath" でこれをやろうとしている/ "getcellを" 方法:
[Export("collectionView:cellForItemAtIndexPath:")]
public UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
{
var cell = (TagCell)collectionView.DequeueReusableCell("tagCell", indexPath);
var thisTag = tags[indexPath.Row];
if (thisTag.color == "undefined") { /* todo: Skip over this cell somehow */ }
try
{
var color = UIColor.Clear.FromHex(thisTag.color);
cell.SetUIWithData(color, thisTag.abbreviation);
cell.AddBorderAndShadow();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"\ncolor : { thisTag.color }\nThrows an exception : \n{ ex }\n");
}
return cell;
}
現在、私のコレクションビューは、TagInstanceがあった場所と定義されていない色の隙間を伴って表示されます。コレクションがそのギャップなしに現れるようにしたいと思います。これは可能ですか?
に次
使用適切な解決策は、あなたのコレクションビューのデータソース内でこれらの値を含めないことです。 – rmaddy
'undefined'要素を除外したフィルタリングされたデータセットを割り当てます。 – SushiHangover