[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 ...
随机推荐
- 6 —— node —— 响应一个完整的页面
const http = require('http'); const fs = require('fs'); const server = http.createServer(); server ...
- Sublime和Python中文编码的一些问题
Windows下的控制台中,应该是这样的逻辑: 1.如果是Unicode字符串的话,首先根据控制台编码进行转换 2.之后进行输出 所以在Windows控制台下,假设str = u'中文', 1.直接p ...
- eclipse启动tomcat访问localhost:8080报404
直接双击tomcat\bin目录下面的startup.bat启动 是没问题 的 但是eclipse启动tomcat访问localhost:8080报404 解决方案如下: 双击红色圈里面的tomcat ...
- 机器学习(ML)一之 Linear Regression
一.线性回归 1.模型 2.损失函数 3.优化函数-梯度下降 #!/usr/bin/env python # coding: utf-8 import torch import time # init ...
- Emacs服务器模式以及emacsclient配置
Emacs有很多强大的插件,但是插件安装多了会导致启动速度很慢.为了解决这个问题,一个方法是使用emacs提供的server模式. 基本用法[1] 启动emacs server: $ emacs -- ...
- JavaScript获取当前日期前后7天的日期
function fun_date(aa){ var date1 = new Date(), time1=date1.getFullYear()+"-"+(date1.getMon ...
- android 开发学习2
Dao dao = new Dao(yi_ji_lu_zhang_dan.this);List<GetOneRecord> list = dao.getAllRecord();//创建迭代 ...
- jdk的配置和安装
1.Jdk的安装和配置 一.安装JDK与配置环境与检验配置成功: 1.进入java.com网站,然后按照以下步骤进行 =>=>等会出现java茶杯双击,一次一次的按下一步,最后会在同一个j ...
- Java IO 乱码
InputStreamReader isr = new InputStreamReader(new FileInputStream("./test/垃圾短信训练集80W条.txt" ...
- 发送邮件的几种方法(C#发邮件 和 js前台实现都有)C#后台自动发邮件 js发邮件
1.后台自动发邮件 1)首先设置邮件参数,这里写在configuration里面 <appSettings> <add key="SMTP" value=&quo ...