I am trying to get a reference to the first cell in collection view in order to move it (for some effect) .
first, can you move a certain cell that is inside the collection ?
second,how would i check if its on visible rect right now? (cells are reusable) .
ERROR: when i do this, i am also getting an error when i set the index path to non zero
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:4];//E
CGRect cellRect = cell.frame;
NSLog(@"%f",cellRect.origin.y);
}
"implicit conversion of int is disallowed in ARC ".
When its set to 0 , i always get position of 0, even when the cell is offscreen.
I guess i am missing the right way to get the first cell ..
You should create an instance of an NSIndexPath to use cellForItemAtIndexPath
Example
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:4 inSection:0];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
CGRect cellRect = cell.frame;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With