今天需求说要给在进入某个页面给某个按钮加上放大效果,心想这还不简单,于是三下五除二的把动画加上提交测试了.

下面是动画的代码

    NSTimeInterval time = CACurrentMediaTime();
time = time + 0.5; CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; //设置value
CATransform3D scale1 = CATransform3DMakeScale(1.1, 1.1, );
CATransform3D scale2 = CATransform3DMakeScale(1.0, 1.0, );
animation.values = @[[NSValue valueWithCATransform3D:scale2],[NSValue valueWithCATransform3D:scale1],[NSValue valueWithCATransform3D:scale2]]; //重复次数 默认为1
animation.repeatCount = ;
//设置是否原路返回默认为NO
animation.autoreverses = NO;
animation.beginTime = time;
animation.duration = 0.5;
animation.keyTimes = @[@0.0,@0.7,@]; animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//给这个view加上动画效果
[view.layer addAnimation:animation forKey:@"transform.scale"];

然而后面却出现了一个诡异的bug.当动画正在进行的时候滚动scrollView,则会崩溃,并且报下面的错误.

[NSConcreteValue doubleValue]: unrecognized selector sent to instance

上stackoverflow上发现解释如下,

The transform.scale should be a double type, if you assign fromValue or toValue of CABasicAnimation a NSValue type, it cann't convert to double value, and so App crashed.

翻译一下就是transform.scale应该用double类型的数值来赋值,如果用NSValue封装好的值来给fromValue和toValue赋值的话,则会解析不到对应的值,表现为app崩溃.

于是修改代码如下,完美运行,不会崩溃了.

    NSTimeInterval time = CACurrentMediaTime();
time = time + 0.5; //设置value
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; //设置value
animation.values = @[@,@1.1,@]; //重复次数 默认为1
animation.repeatCount = ;
//设置是否原路返回默认为NO
animation.autoreverses = NO;
animation.beginTime = time;
animation.duration = 0.5;
animation.keyTimes = @[@0.0,@0.7,@]; animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//给这个view加上动画效果
[view.layer addAnimation:animation forKey:@"transform.scale"];

[NSConcreteValue doubleValue]: unrecognized selector sent to instance的更多相关文章

  1. '-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d89a50'

    类型:ios 问题描述: 导入百度地图 然后在模拟器运行可以,真机测试不行: 报错: '-[__NSCFString stringFromMD5]: unrecognized selector sen ...

  2. unrecognized selector sent to instance

    今天长一见识(特此感谢小星星老湿-坏笑),凡是遇到“unrecognized selector sent to instance *******”的都是******方法没有,比如这种的错误: 可以尝试 ...

  3. IOS 错误 [UIWebView cut:]: unrecognized selector sent to instance

    那在什么场景中会出现这种情况呢? 如果一个包含文字的输入元素有焦点,然后按钮的点击会导致输入失去焦点,然后接下来在输入时双按会重新得到焦点并从弹出bar中选择剪切复制粘贴,就会导致此error. 也就 ...

  4. iOS 程序报错:reason: [NSArrayI addObject:]: unrecognized selector sent to instance

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI ad ...

  5. -[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3

    网络数据解析出现-[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3这样的错误,具体 re ...

  6. CBUUID UUIDString unrecognized selector sent to instance 错误

    CBUUID UUIDString unrecognized selector sent to instance 错误 ios7.0,4s 蓝牙出现上述错误! 查看api可知,错误原因,由于CBUUI ...

  7. reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance

    reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 发现上线的app一直会有这个cr ...

  8. 利用objc的runtime来定位次线程中unrecognized selector sent to instance的问题

    昨天遇到一个仅仅有一行错误信息的问题: -[NSNull objectForKey:]: unrecognized selector sent to instance 0x537e068 因为这个问题 ...

  9. unrecognized selector sent to instance 0x10b34e810

    一个错误: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLEr ...

随机推荐

  1. P1053 住房空置率

    P1053 住房空置率 转跳点:

  2. UVA - 1513 Movie collection (树状数组)

    题意:有n个影碟,标号为1~n,位置为0~n-1,每次取出一个影碟看完后,将其放在最前面(标号为0处),问每个影碟取出前,其位置之前有多少个影碟. 分析: 1.数组大小开为100000*2,后1000 ...

  3. 每天一点点之vue框架开发 - @click-native-prevent

    1.在封装好的组件上使用,所以要加上.native才能click 2.prevent就相当于..event.preventDefault() 所以@click.native.prevent是用来阻止默 ...

  4. netty权威指南学习笔记三——TCP粘包/拆包之粘包现象

    TCP是个流协议,流没有一定界限.TCP底层不了解业务,他会根据TCP缓冲区的实际情况进行包划分,在业务上,一个业务完整的包,可能会被TCP底层拆分为多个包进行发送,也可能多个小包组合成一个大的数据包 ...

  5. CSS - 美化字体 => CSS的-font-smoothin属性优化

    body{     margin: 0;     font-family: Arial, Helvetica, sans-serif;     line-height: 1.2em;     back ...

  6. Vue.js(25)之 vue全局配置api介绍

    本文介绍的全局api并不在Vue的构造函数内,而是在Vue构造器外面提供这些方法,让我们扩展新功能. 1. vue.extend(options) 参考:https://www.w3cplus.com ...

  7. 解决Spring Mvc中接受参数绑定重名的方法

    html页面 <form method='post' action='url'> 用户名 <input type='text' name='name'> 用户id <in ...

  8. Java算法练习——最长公共前缀

    题目链接 题目描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 说明: 所有输入只包含小写字母 a-z . 示例 1 输入: [&qu ...

  9. Jeesite 定时任务 Task

    转自 http://blog.lunhui.ren/archives/280 第一种方式 一. spring-context.xml配置加入 xmlns:task=”http://www.spring ...

  10. iOS应用内跳转到指定系统设置页

    APP的跳转: 通过[ [UIApplication sharedApplication] openURL:url]这种方法来实现的. iOS 10以后跳转设置页要用 [[UIApplication ...