我正在创建的iOS应用中有一些基本的动画,效果一直很好……直到昨天。

我显然进行了某种更改,以某种方式影响了它,但是我无法确定问题所在。

单步执行代码时,它到达了这段代码,并在超过commitAnimation行之后死掉了(我最初写此代码是在意识到[UIView animateWithDuration:...]之美之前:

UIView *favoritesTabItemView = [appDelegate.tabBarController.tabBar viewWithTag:0];
CGPoint startingPoint = [[magazineView superview]
convertPoint:CGPointMake(magazineView.center.x, magazineView.center.y) toView:appDelegate.window.rootViewController.view];
CGPoint targetPoint = CGPointMake(favoritesTabItemView.center.x - 214.0, favoritesTabItemView.center.y);

//shrink the icon down
UIGraphicsBeginImageContextWithOptions(magazineView.bounds.size, NO, 0.0);
[magazineView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[UIImageView beginAnimations:nil context:nil];
[UIImageView setAnimationDuration:0.1];
PublicationCoverImageReflectionView.alpha = 0.0;
[UIImageView commitAnimations];  //<-- crash happens after this line


我越过commitAnimation之后,调试器的错误给了我很少的帮助:

*** Terminating app due to uncaught exception 'NSRangeException', reason:
'*** -[__NSArrayM objectAtIndex:]: index 9 beyond bounds [0 .. 8]'
*** First throw call stack:
(0x35c8b88f 0x31604259 0x35bd49db 0x126d5d 0x12e65f 0x349da6c9 0x34a66531 0x35c57547 0x35be3097 0x349da3eb 0x307a3a13 0x10f8ef 0x35be53fd 0x307a9faf 0x307a9f6b 0x307a9f49 0x307a9cb9 0x307aa5f1 0x307a8ad3 0x307a84c1 0x3078e83d 0x3078e0e3 0x3596122b 0x35c5f523 0x35c5f4c5 0x35c5e313 0x35be14a5 0x35be136d 0x35960439 0x307bce7d 0xbb109 0xbb0c8)
terminate called throwing an exception(lldb)


有谁知道这可能在谈论哪种数组?这是一个垂死的UIKit调用,因此我认为该数组是UIKit使用的某些视图数组,但我对...无视。

关于如何解决甚至进一步调查的任何想法都很棒!

最佳答案

尝试将UIImageView切换为UIView

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.1];
PublicationCoverImageReflectionView.alpha = 0.0;
[UIView commitAnimations];

关于objective-c - 如何调试UIKit的CoreAnimation调用触发的崩溃?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11586470/

10-13 04:08