Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 集合视图单元动画电视操作系统_Ios_Objective C_Uicollectionview_Uicollectionviewcell_Tvos - Fatal编程技术网

Ios 集合视图单元动画电视操作系统

Ios 集合视图单元动画电视操作系统,ios,objective-c,uicollectionview,uicollectionviewcell,tvos,Ios,Objective C,Uicollectionview,Uicollectionviewcell,Tvos,我正在尝试设置集合视图单元格的动画,这是到目前为止我的代码 - (void)collectionView:(UICollectionView *)collectionView didUpdateFocusInContext:(UICollectionViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator{ UICollectionViewCe

我正在尝试设置集合视图单元格的动画,这是到目前为止我的代码

- (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
        }];
    }
但是我的代码不起作用。我已经阅读了文档,它说要实现以下内容
如果(self==contextFocusedView)。。。。。。但它有一个警告说,不兼容的指针视图控制器指向UIView。有人能告诉我我的代码出了什么问题以及如何修复它吗?谢谢

所以我最终找到了答案。我的collectionView中有一个UIImage。电视操作系统UIImage的一个属性是调整聚焦时的图像。因此,如果您在viewDidLoad中设置此选项,则如下所示:

    _imageView.adjustsImageWhenAncestorFocused = Yes;
或者,选中故事板中的“聚焦时调整图像”框。这将聚焦图像。我还没有尝试过标签。或者您可以在集合视图单元格中添加的任何其他元素,但我相信也有类似的内容


快乐编程的家伙!(:

dequeueReusableCellWithReuseIdentifier:
将不返回当前视图,而是返回一个新视图。 尝试使用
cellForItemAtIndexPath:

但为什么不使用:

if (context.nextFocusedView) {
    [coordinator addCoordinatedAnimations:^{
        context.nextFocusedView.transform = CGAffineTransformMakeScale(1.1, 1.1);
    } completion:nil];
}
if (context.previouslyFocusedView) {
    [coordinator addCoordinatedAnimations:^{
        context.previouslyFocusedView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    } completion:nil];
}

汉内斯基答案的Swift 2.0版本:

override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
    if (context.nextFocusedView != nil) {
        coordinator.addCoordinatedAnimations({() -> Void in
            context.nextFocusedView!.transform = CGAffineTransformMakeScale(1.1, 1.1)
            }, completion: { _ in })
    }
    if (context.previouslyFocusedView != nil) {
        coordinator.addCoordinatedAnimations({() -> Void in
            context.previouslyFocusedView!.transform = CGAffineTransformMakeScale(1.0, 1.0)
            }, completion: { _ in })
    }
}

这将缩放整个单元格,包括所有标签…

我认为您不应该拥有
else if
,而应该是
if
。先生,您应该获得一枚奖章!谢谢!)这将缩放包括标签在内的整个单元格,而不是仅在imageview上显示效果,并保持其他对象不变。如果单元格中没有包含图像,则如何?@AlizainPrasla我所做的是通过编程增加和减少视图的大小。与下面的答案相似,我得到了你的答案,但如果牢房里没有图像呢。我没有uimageview的任何IBoutlet,它如何工作