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

下面是动画的代码

    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. 剑指offer自学系列(一)

    题目描述:输入n个整数,找出其中最小的k个数,例如,输入{4,5,1,6,2,7,3,8}这8个数字,最小的4个数字是1,2,3,4 题目分析:首先我能想到的是先对数组排序,从小到大,然后直接输出想要 ...

  2. vCenter组件和服务

    1).随VMware Platform Services Controller一起安装的服务 a. vCenter Single Sign-On身份验证服务 b. vSphere 许可证服务 c. V ...

  3. 将数据写入已有的excel文件

    /** * 将反馈结果写入excel中 * */ public static void writeExcelResult(String url,List<Integer> result) ...

  4. jenkins打包iOS 报错:error: exportArchive: The data couldn’t be read because it isn’t in the correct format.

    在执行ios 打包的时候,我们通过执行下面的指令来打包ipa: mkdir arch archive_path=arch/${app_name}.xcarchive workspace_name=HP ...

  5. Java Integer Addition Subtration Overflow 整数加减溢出

    leetCode有道题Reverse Integer,因为int的最大值为2的31次方减一,最小值为-2的31次方. 我一开始的代码将res递归加放在try中,以为溢出会有异常,然而并没有. 因为出传 ...

  6. Eclipse 中打开工程目录的插件

    我们想在Eclipse中的打开工程目录,Eclipse 自身没有这个功能,我们可以安装一个插件来实现这个功能.具体的操作方法如下: (1).到以下链接中下载插件:https://github.com/ ...

  7. ACM-Alice and Bob

    题目描述:Alice and Bob One day, Alice asks Bob to play a game called “K-in-a-row”. There is a game board ...

  8. 第二十一篇 关联管理器(RelatedManager)

    关联管理器(RelatedManager) lass RelatedManager "关联管理器"是在一对多或者多对多的关联上下文中使用的管理器.它存在于下面两种情况: Forei ...

  9. Django配置日志

    在settings里配置 # 日志配置 LOGGING = { # 是python的版本 'version': 1, # 是否禁用 'disable_existing_loggers': False, ...

  10. C#后台执行JavaScript

    方法一: Page.RegisterClientScriptBlock 方法 命名空間: System.Web.UI 这个方法现在已经过时.改用ClientScriptManager.Register ...