本人ios编程小白一个,正在学,跟着视频打代码,运行出了这么个错,找了半天也没看出来,各位大大帮忙看下,代码就是tom猫的一个小程序
错误日志
unrecognized selector sent to instance 0x7fbd20627180
2015-07-21 10:52:58.264 Tom[8325:418012] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController drink:]: unrecognized selector sent to instance 0x7fbd20627180'
代码
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *tom;
@end
@implementation ViewController
-(void)tomAnimation:(NSString *)img count:(int)count
{
if([self.tom isAnimating]) return;
NSMutableArray *arrayM = [NSMutableArray array];
for (int i = 0; i < count; i++) {
NSString *imageName = [NSString stringWithFormat:@"%@_%02d.jpg",img,i];
// UIImage *image = [UIImage imageNamed:imageName];
NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
UIImage *image = [UIImage imageNamed:path];
NSLog(@"image is %@ and id is %02d",image,i);
[arrayM addObject:image];
}
[self.tom setAnimationImages:arrayM];
[self.tom setAnimationDuration:arrayM.count * 0.1];
[self.tom setAnimationRepeatCount:1];
//2.开始动画
[self.tom startAnimating];
//动画完成之后,再清除动画数组内容
[self performSelector:@selector(clearTom) withObject:nil afterDelay:self.tom.animationDuration];
}
-(void)clearTom
{
self.tom.animationImages = nil;
}
- (IBAction)drink
{
//序列帧动画,所谓序列帧动画,就是让一组图片一张一张的顺序播放
//1.图片的数组
[self tomAnimation:@"drink" count:81];
}
@end