我試圖動畫集合觀察室,這是我到目前爲止的代碼Collection視圖細胞動畫tvOS
- (void)collectionView:(UICollectionView *)collectionView didUpdateFocusInContext:(UICollectionViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator{
UICollectionViewCell *nextFocusedCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"VideoCell" forIndexPath:context.nextFocusedIndexPath];
UICollectionViewCell *previousFocusedCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"VideoCell" forIndexPath:context.previouslyFocusedIndexPath];
if (context.nextFocusedView) {
[coordinator addCoordinatedAnimations:^{
[nextFocusedCell setFrame: CGRectMake(3, 14, 300, 300)];
} completion:^{
// completion
}];
} else if (context.previouslyFocusedView) {
[coordinator addCoordinatedAnimations:^{
[previousFocusedCell setFrame: CGRectMake(3, 14, 100, 100)];
} completion:^{
// completion
}];
}
但我的代碼是行不通的。我已閱讀文檔,它說如果(自== contextFocusedView)實現類似 ......但它有一個警告說,不兼容的指針視圖控制器到UIView。有人能告訴我什麼是我的代碼錯誤&如何解決它?謝謝!!
我不認爲你應該有'else if',而只是'if'。 – Banana