我想調用我的方法,突出顯示UICollectionViewCells我有..一切工作正常,但當UIView第一次加載我試圖選擇集合視圖中的第一個項目像這樣什麼都沒有發生時,我打電話CollectionView:didSelectItemAtIndexPath
[photoCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UICollectionViewScrollPositionNone];
這是我的選擇方法看起來像選擇照片時,甜蜜的作品。
#pragma mark -- UICollectionView Delegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
oldCell = currentCell;
currentCell = indexPath;
// animate the cell user tapped on
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
UICollectionViewCell *oCell = [collectionView cellForItemAtIndexPath:oldCell];
NSDictionary *currentSelectedDict = [imageArray objectAtIndex:indexPath.row];
UIImage *updatePreviewImage = [UIImage imageWithData:[currentSelectedDict objectForKey:@"DImage"]];
[previewImageView setImage:updatePreviewImage];
previewImageView.userInteractionEnabled = YES;
typeTextF.text = [currentSelectedDict objectForKey:@"DocumentType"];
descriptionText.text = [currentSelectedDict objectForKey:@"DocumentDescription"];
dateLabel.text = [NSString stringWithFormat:@"%@", [currentSelectedDict objectForKey:@"DateString"]];
[UIView animateWithDuration:0.2
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
NSLog(@"animation start");
[cell setBackgroundColor:[UIColor whiteColor]];
[oCell setBackgroundColor:[UIColor clearColor]];
}
completion:^(BOOL finished){
NSLog(@"animation end");
[cell setBackgroundColor:[UIColor whiteColor]];
[oCell setBackgroundColor:[UIColor clearColor]];
}
];
}
我讀過,也許你可以調用這個方法太早?我不確定這是否是這種情況,但我不知道如何測試它,或者如果我使用的代碼甚至是正確的。
任何幫助,將不勝感激。
對此表示感謝。 – HurkNburkS