ios开发-Object c 错误unrecognized selector sent to instance

作者:用户 来源:互联网 浏览:489 次 时间:2016-09-28 09:54:59

ios开发objetive c

ios开发-Object c 错误unrecognized selector sent to instance - 摘要: Objectc错误unrecognizedselectorsenttoinstance本人ios编程小白一个,正在学,跟着视频打代码,运行出了这么个错,找了半天也没看出来,各位大大帮忙看下,代码就是t

问题描述

Object c 错误unrecognized selector sent to instance

本人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

解决方案

iOS开发之unrecognized selector sent to instance错误
unrecognized selector sent to instance
发生错误unrecognized selector sent to instance的原因

解决方案二:

方法和类(对象)之间没有对应,也就是对象的类中没有这个方法

解决方案三:

将最后一段改为这个试一试

  • (IBAction)drink:(id)sender { //序列帧动画,所谓序列帧动画,就是让一组图片一张一张的顺序播放 //1.图片的数组 [self tomAnimation:@"drink" count:81]; }
【云栖快讯】你想见的Java技术专家都在这了,向大佬提问,有问题必答  详情请点击
云栖社区(yq.aliyun.com)为您免费提供ios开发-Object c 错误unrecognized selector sent to instance相关信息,包括 ios开发 objetive c 的信息 ,所有ios开发-Object c 错误unrecognized selector sent to instance相关内容均不代表云栖社区的意见! 该页面h5页面的地址是:https://m.aliyun.com/yunqi/wenzhang/show_44867,您可以点击ios开发-Object c 错误unrecognized selector sent to instance-手机站访问。
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率

40+云计算产品,6个月免费体验

现在注册,免费体验40+云产品,及域名优惠!

云服务器9.9元/月,大学必备

热点导航