【发布时间】:2017-03-15 23:02:27
【问题描述】:
我有一个“TagInstances”列表,每个都包含一个“颜色”字符串值。
List<TagInstance> tags
在我的 UICollectionView 中,如果:
tags[index.Path].color = "undefined"
我试图在“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 具有和未定义颜色的间隙。我希望这个系列的出现没有那个间隙。这可能吗?
【问题讨论】:
-
正确的解决方案是不在您的集合视图数据源中包含这些值。
-
分配一个排除
undefined元素的过滤数据集..
标签: ios xamarin xamarin.ios uicollectionview