I have a collection view, but cell that are not appearing in the screen i cannot access, 1...5 ok, and those at index parth row 6, 7, and they have to be scrolled to bee seen
func Action0(sender: UIButton!) {
for i in 0...7 {
if i != 0{
var indexPath = NSIndexPath(forRow: i, inSection: 0)
var cell = collectionView!.cellForItemAtIndexPath(indexPath)
cell!.backgroundColor = UIColor.whiteColor()
}else{
var indexPath = NSIndexPath(forRow: 0, inSection: 0)
var cell = collectionView!.cellForItemAtIndexPath(indexPath)
cell!.backgroundColor = UIColor.blueColor()
}
}
}
How to acces those cells that are not yet visible?
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as! CollectionViewCell
cell.backgroundColor = UIColor.blackColor()
cell.textLabel.text = "\(indexPath.section):\(indexPath.row)"
cell.buttonView.setBackgroundImage(UIImage(named: "Good"), forState: UIControlState.Normal)
cell.buttonView.addTarget(self, action: Selector("Action\(indexPath.row):"), forControlEvents: UIControlEvents.TouchUpInside)
return cell
}