ios - 'UIInterpolatingMotionEffect' 没有可见的@interface 声明选择器 'initWithKeyPath:type:'

标签 ios objective-c uimotioneffect

我遇到了 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/

相关文章:

ios - UIView 之上的 AVPlayer

ios - 如何从> 2个信号生成器中的任何一个触发 block ?

ios - UIMotionEffect 的视差效果不起作用

iphone - 有人可以给我展示 View Controller 如何工作的图表吗?

swift - tvOS:UIButton 的 UIMotionEffect 滑动时不会反弹

ios - 无法使用 UIVIew 更新 | iOS swift

iphone - 实现自定义 NSMutableArray

objective-c - 在 Objective-C 中,我试图封装多个可能出错的调用和 "return"最有用的错误

ios - 阻止 UIButton 的 setTitle :forState: animation