didSelectItemAtIndexPathに、コレクションビューの任意のセルの値を設定する方法。だから私は他のすべてのセルの境界線の色を黒に変えたいと思っています。UICollectionViewController(Swift)のメソッドdidSelectItemAtIndexPath()ですべてのセルにアクセスする方法
はあなたに
didSelectItemAtIndexPathに、コレクションビューの任意のセルの値を設定する方法。だから私は他のすべてのセルの境界線の色を黒に変えたいと思っています。UICollectionViewController(Swift)のメソッドdidSelectItemAtIndexPath()ですべてのセルにアクセスする方法
はあなたに
あなたが選択し、インデックス
var isSelected:Bool = false;
var index: Int;
のための参照を維持することによって、これを達成し、didSelectItemAtIndexPathでtrueにisselectedプロパティを変更し、コレクションビュー
をリロードインデックスにインデックスパスの行の値を保つことができますセルを入力すると、条件が追加されます。
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if(isSelected && indexPath.Row != index)
{
// change the color to the black
}
}
次のコードはテーブルビューのセクションを反復処理し、各セクションの行をありがとうございました。各行のindexPathと選択したセルのindexPathを比較し、一致しない場合は、セルに行う必要があることを実行できます。
for (NSInteger i = 0; i < [tableView numberOfSections]; ++i)
{
for (NSInteger j = 0; j < [tableView numberOfRowsInSection:i]; ++j)
{
NSIndexPath *cellIdxPath = [NSIndexPath indexPathForRow:j inSection:i];
// indexPath represents the currently selected row
if (indexPath != cellIdxPath)
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:cellIdxPath];
// do whatever you need to do to the cell
}
}
}