这是我遇到的最奇怪的错误。
我试图将倒计时动画添加到扩展UIView的类上。代码如下所示:
NSArray *myImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"3.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"Go.png"], nil];
UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 80, 80)];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 3;
myAnimatedView.animationRepeatCount = 0;
[self addSubview:myAnimatedView];
[myAnimatedView startAnimating];
它只是没有出现在屏幕上。任何想法?
答案 0 :(得分:1)
您确定这些图片是否已添加到您的项目中?
您可以将它们添加为平面图像(非动画) - 如:
UIImageView *myAnimatedView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"3.png"]];
[self addSubview:myAnimatedView];
(只是为了确保首先工作)?
如果你扩展UIImageView而不是扩展UIView,那会有所作为吗?
答案 1 :(得分:0)
尝试切换最后两行。来自:
[self addSubview:myAnimatedView];
[myAnimatedView startAnimating];
致:
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];