UIInterpolatingMotionEffect随机工作

Ian*_*Ian 6 objective-c uitableview ios

我正在UIInterpolatingMotionEffectUITableViewCell这种方式添加一些视图:

UIInterpolatingMotionEffect *horizontalEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
UIInterpolatingMotionEffect *verticalEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
horizontalEffect.minimumRelativeValue = @(-horizontal);
horizontalEffect.maximumRelativeValue = @(horizontal);
verticalEffect.minimumRelativeValue = @(-vertical);
verticalEffect.maximumRelativeValue = @(vertical);

UIMotionEffectGroup *effectsGroup = [UIMotionEffectGroup new];
effectsGroup.motionEffects = @[horizontalEffect, verticalEffect];

[view addMotionEffect:effectsGroup];
Run Code Online (Sandbox Code Playgroud)

问题是效果只是随机出现,有些视图会产生效果而有些视图不会产生效果.推送视图控制器并返回后,其他一些工作,而其他人则不工作.

有什么我想念的吗?是否应该在每次重复使用细胞时应用效果?

Ric*_*erg 0

我有同样的问题。我通过强制重绘所有单元格来修复它 - 使用 reloadSections:withRowAnimation: 可能对大多数人(或类似的方法)有效,尽管对我来说,我最终不得不编写自己的单元格初始化并重用代码,让我保留引用可变数组中每个创建的单元格,然后清除该数组并在我选择时从头开始构建。希望有帮助。