子分类UIView错误

jar*_*ryd 0 core-animation uiview ios

当我将一个xib类设置为UIView的子类,然后animateWithDuration在UIView上我得到了

No visible @interface for 'UIView' declares the selector
'animateWithDuration:delay:options:animations:completion:' 
Run Code Online (Sandbox Code Playgroud)

错误窗格显示它是ARC问题

在此输入图像描述

我想在UIView上运行动画.

编辑:导致错误的代码

 [sampleSourceView.view animateWithDuration:1
                                             delay:1.0
                                           options: UIViewAnimationCurveEaseOut
                                        animations:^{
                                            sampleSourceView.view.frame = sampleSourceFrame;
                                        } 
                                        completion:^(BOOL finished){
                                            NSLog(@"Done!");
                                        }];

        [self.view addSubview:sampleSourceView.view];
Run Code Online (Sandbox Code Playgroud)

sos*_*orn 6

您收到错误是因为您正在尝试在UIView的实例上使用类方法.查看方法签名:

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
Run Code Online (Sandbox Code Playgroud)

加号表示它是一种类方法.实例方法将具有减号.

试试这个:

[UIView animateWithDuration:1
                     delay:1.0
                   options: UIViewAnimationCurveEaseOut
                animations:^{
                    sampleSourceView.view.frame = sampleSourceFrame;
                } 
                completion:^(BOOL finished){
                    NSLog(@"Done!");
                }];
Run Code Online (Sandbox Code Playgroud)