我遇到了 UIInterpolatingMotionEffect
类并出现问题,应用程序可以编译,但是当我尝试存档时出现此编译错误:
'UIInterpolatingMotionEffect' 的可见@interface 声明选择器'initWithKeyPath:type:'
我在这个函数的 UIInterpolatingMotionEffect
初始化程序中遇到了这个错误:
- (void)addMotionEffects
{
UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
horizontalMotionEffect.minimumRelativeValue = @(-20);
horizontalMotionEffect.maximumRelativeValue = @(20);
UIInterpolatingMotionEffect *verticalMotionEffect = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
verticalMotionEffect.minimumRelativeValue = @(-20);
verticalMotionEffect.maximumRelativeValue = @(20);
UIMotionEffectGroup *group = [UIMotionEffectGroup new];
group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect];
[self.containerView addMotionEffect:group];
}
我认为这是尝试为 arm64 架构编译时的一种错误,但我无法弄清楚如何解决该问题。
有什么想法吗?
最佳答案
这是一个 WTF 答案,也是一个 WTF 问题,但有效...
为了避免编译错误,我为 UIInterpolatingMotionEffect
创建了一个类别,其中包含给出错误的选择器。但是仍然不知道为什么 Xcode 没有这个就不能存档......
@interface UIInterpolatingMotionEffect (lol)
- (instancetype)initWithKeyPath:(NSString *)keyPath type:(UIInterpolatingMotionEffectType)type;
@end
关于ios - 'UIInterpolatingMotionEffect' 没有可见的@interface 声明选择器 'initWithKeyPath:type:',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27124318/