大佬教程收集整理的这篇文章主要介绍了iphone – CALayerInvalidGeometry’,原因:’CALayer边界包含NaN:[0 0;南南]崩溃,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
CALayerInvalidGeometry’,原因:’CALayer bounds包含NaN:[0 0;南南]
基本上我在这里是一个视图,使图像褪色和缩放。我最近决定在UIView动画中使用CGAffineTransformScale来改变我的代码,而不是每次定时器打勾时缩放一切。这样使用的方式更少的处理能力。
但是无论我有什么顺序,照片都会在第19个之后崩溃。它所涉及的定位坐标数组似乎并不是一个问题,因为它只有6个长度,并在它达到它的长度后循环。所以出于某些原因,由于我已经实现了这个动画代码,它给了我那个崩溃。任何人都知道为什么
这是我开始崩溃以来发生了变化的部分:
-(void) onTimer{ if(scaleTimer_A==5){ imageView_A.image = [UIImage imagenamed:[attractList_A objectATindex:imageIndex_A]]; imageView_A.frame = CGRectMake(300,200,3.86,3.86); imageView_A.center = CGPointMake(attractLocs_x_A[attractLocs_A_index],attractLocs_y_A[attractLocs_A_index]); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2]; imageView_A.alpha = 1; imageView_A.transform = CGAffineTransformScale(imageView_A.transform,100,100); [UIView commitAnimations]; } if(scaleTimer_A==10){ [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:.75]; imageView_A.alpha = 0; imageView_A.transform = CGAffineTransformScale(imageView_A.transform,1.2,1.2); [UIView commitAnimations]; scaleTimer_A=0; imageIndex_A+=1; if(imageIndex_A==imageIndex_A_sizE){ imageIndex_A=0; } attractLocs_A_index+=1; if(attractLocs_A_index==attractLocs_A_SIZE){ NSLog(@"@R_696_11442@k to zero A"); attractLocs_A_index=0; } NSLog(@"Image A =%@",[attractList_A objectATindex:imageIndex_A]); } scaleTimer_A+=1;}
编辑:
下面是我如何使用CGAffineTransformIdentity在上面的代码中没有崩溃的问题。
-(void) onTimer{ if(scaleTimer_A==5){ imageView_A.image = [UIImage imagenamed:[attractList_A objectATindex:imageIndex_A]]; imageView_A.transform = CGAffineTransformIdentity; imageView_A.center = CGPointMake(attractLocs_x_A[attractLocs_A_index],attractLocs_y_A[attractLocs_A_index]); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2]; imageView_A.alpha = 1; imageView_A.transform = CGAffineTransformScale(CGAffineTransformIdentity,100); [UIView commitAnimations]; } if(scaleTimer_A==10){ [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:.75]; imageView_A.alpha = 0; imageView_A.transform = CGAffineTransformScale(CGAffineTransformIdentity,120,120); [UIView commitAnimations]; scaleTimer_A=0; imageIndex_A+=1; if(imageIndex_A==imageIndex_A_sizE){ imageIndex_A=0; } attractLocs_A_index+=1; if(attractLocs_A_index==attractLocs_A_SIZE){ NSLog(@"@R_696_11442@k to zero A"); attractLocs_A_index=0; } NSLog(@"Image A =%@",[attractList_A objectATindex:imageIndex_A]); } scaleTimer_A+=1;}
imageView_A.frame = CGRectMake(300,3.86);
尝试将imageView_A.transform设置为标识。另一个解决方案(我觉得更好)会使用UIScrollView进行缩放(也可以被制作为动画)。
编辑:尝试这个
imageView_A.image = [UIImage imagenamed:[attractList_A objectATindex:imageIndex_A]]; imageView_A.frame = CGRectMake(300,attractLocs_y_A[attractLocs_A_index]); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2]; imageView_A.alpha = 1; imageView_A.frame = CGRectMake(300,386.0f,386.0f); [UIView commitAnimations];
以上是大佬教程为你收集整理的iphone – CALayerInvalidGeometry’,原因:’CALayer边界包含NaN:[0 0;南南]崩溃全部内容,希望文章能够帮你解决iphone – CALayerInvalidGeometry’,原因:’CALayer边界包含NaN:[0 0;南南]崩溃所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。