当我将一个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];
答案 0 :(得分:6)
您收到错误是因为您正在尝试在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!");
}];