// 卡片类的头文件
#import "OWCardView.h"
@implementation OWCardView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.layer.contents = (id) [UIImage imageNamed:@"4.png"].CGImage;
self.layer.shadowColor = [UIColor whiteColor].CGColor;
self.layer.shadowOpacity = 0.3;
}
return self;
}
- (void) moveCard:(float)xPoint along:(float)yPoint
{
CGRect someRect = CGRectMake(xPoint, yPoint, 72, 96);
[UIView animateWithDuration: 3.5
delay: 0.3
options: UIViewAnimationCurveEaseOut
animations: ^{ self.frame = someRect;}
completion: ^(BOOL finished) { }];
}
@end
// part of the Implementation in the view controller's viewDidLoad
[...]
CGRect myImageRect = CGRectMake(20.0f, 20.0f, 72.0f, 96.0f);
// myCard is a property of the viewController
self.myCard = [[OWCardView alloc] initWithFrame:myImageRect];
[self.view addSubview:self.myCard];
[self.myCard moveCard: 240 along: 355]; // First call
[self.myCard moveCard: 50 along: 355]; // Second call
[self.myCard moveCard: 50 along: 50]; // Third call
[...]
问题:只执行viewController中moveCard的最后一条消息;第一次和第二次调用不执行。代码有什么问题?
当我将第三条消息注释到 moveCard 时,第二个调用被执行,而第一个没有。如果我注释了第二个和第三个调用,则执行第一个调用。但我希望所有三个动画都出现在卡片上。