[NSConcreteValue doubleValue]: unrecognized selector sent to instance
今天需求说要给在进入某个页面给某个按钮加上放大效果,心想这还不简单,于是三下五除二的把动画加上提交测试了.
下面是动画的代码
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的更多相关文章
- '-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d89a50'
类型:ios 问题描述: 导入百度地图 然后在模拟器运行可以,真机测试不行: 报错: '-[__NSCFString stringFromMD5]: unrecognized selector sen ...
- unrecognized selector sent to instance
今天长一见识(特此感谢小星星老湿-坏笑),凡是遇到“unrecognized selector sent to instance *******”的都是******方法没有,比如这种的错误: 可以尝试 ...
- IOS 错误 [UIWebView cut:]: unrecognized selector sent to instance
那在什么场景中会出现这种情况呢? 如果一个包含文字的输入元素有焦点,然后按钮的点击会导致输入失去焦点,然后接下来在输入时双按会重新得到焦点并从弹出bar中选择剪切复制粘贴,就会导致此error. 也就 ...
- iOS 程序报错:reason: [NSArrayI addObject:]: unrecognized selector sent to instance
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI ad ...
- -[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3
网络数据解析出现-[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3这样的错误,具体 re ...
- CBUUID UUIDString unrecognized selector sent to instance 错误
CBUUID UUIDString unrecognized selector sent to instance 错误 ios7.0,4s 蓝牙出现上述错误! 查看api可知,错误原因,由于CBUUI ...
- reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance
reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 发现上线的app一直会有这个cr ...
- 利用objc的runtime来定位次线程中unrecognized selector sent to instance的问题
昨天遇到一个仅仅有一行错误信息的问题: -[NSNull objectForKey:]: unrecognized selector sent to instance 0x537e068 因为这个问题 ...
- unrecognized selector sent to instance 0x10b34e810
一个错误: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLEr ...
随机推荐
- tornado peewee_async
https://peewee-async.readthedocs.io/en/latest/peewee_async/examples.html https://www.cnblogs.com/Vic ...
- uni-app解决小程序圆角样式不生效
在使用uni-app实现小程序的时候,设置左图的右圆角不生效,样式也都没有问题,在模拟器上也可以正常现实,手机上样式出现差别,现有以下解决方法: 设置整个圆角,然后左边使用margin-left:-3 ...
- s5pc100开发板网卡驱动的移植
相关软件下载地址:http://pan.baidu.com/s/16yo8Y fsc100开发板 交叉编译工具:arm-cortex_a8-linux-gnueabi-gcc 平台代码修改 vim ...
- python itertools 用法
1.介绍itertools 是python的迭代器模块,itertools提供的工具相当高效且节省内存.使用这些工具,你将能够创建自己定制的迭代器用于高效率的循环.- 无限迭代器 itertools包 ...
- 九十六、SAP中ALV事件之九,显示功能按钮栏中显示ALV加强工具栏
一.排查了很久,终于找到问题所在.把问题解决了,代码如下: 二.运行效果如下 三.试一试,标准功能都可以用 完美
- echarts 柱状图的选中模式实现-被选中变色和再次选中为取消变色
方法: function barCharShow(curr_dim,divId,result_data){ mutilDim(curr_dim);//维度信息 var paint = initEcha ...
- phpStudy配置站点解决各种不能访问问题(本地可www.xx.com访问)
1.配置站点:打开phpStudy->其他选项菜单->站点域名管理 2.配置站点:打开phpStudy->其他选项菜单->打开hosts(www访问重点) 3.在apache的 ...
- python+selenium 发送邮件
import time from selenium import webdriver from selenium.webdriver import ChromeOptions from seleniu ...
- Http协议Get与Post请求
摘要:https://blog.csdn.net/kebi007/article/details/103059900 不就是get拼接url,post传body,get限制字符串长度吗! 请求缓存:G ...
- BZOJ:2244: [SDOI2011]拦截导弹
问题: printf("%.5f ",0):为什么错了? 注意: 初始值很重要 题解: 三维偏序问题: 记录从前往后最长上升子序列长度pref,条数preg 从后往前suff,su ...