【问题标题】:Sub Classing UIView Error子类 UIView 错误
【发布时间】:2012-07-05 01:47:59
【问题描述】:

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

No visible @interface for 'UIView' declares the selector
'animateWithDuration:delay:options:animations:completion:' 

错误窗格显示这是一个 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];

【问题讨论】:

  • 你能贴出导致错误的代码吗?

标签: ios uiview core-animation


【解决方案1】:

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

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

加号表示它是一个类方法。实例方法会有一个减号。

试试这个:

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

【讨论】:

    猜你喜欢
    • 2014-08-21
    • 1970-01-01
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多