2016-08-12 4 views

答えて

0

あなたが選択し、インデックス

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 
    } 

} 
0

次のコードはテーブルビューのセクションを反復処理し、各セクションの行をありがとうございました。各行の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 
     } 
    } 
} 
関連する問題