【发布时间】:2013-10-11 13:43:38
【问题描述】:
我正在以这种方式在UITableViewCells 中的某些视图中添加UIInterpolatingMotionEffect:
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];
问题是效果只是随机出现,有些视图有效果,有些没有。推送视图控制器并返回后,其他一些可以工作,而另一些则不能。
我有什么遗漏吗?每次重用单元格时是否应该应用效果?
【问题讨论】:
-
这段代码在哪里?它在你的 cellForRowAtIndexPath 中还是在哪里?
-
或多或少,我在创建单元格时添加了运动效果。
-
尽量不要使用 UIMotioneffectGroup 而是像这样添加两个动作效果:[view addMotionEffect:horizontalEffect];和 [查看 addMotionEffect:verticalEffect];
-
不幸的是,这似乎没有任何区别。
-
这里(几乎)相同。有没有解决这个问题?
标签: ios objective-c uitableview