2

約 5 ~ 7 分間アイドリングした後、XCode でアプリがクラッシュします。ロード画面に使用されているアニメーションと関係があると確信しています-以下のコードを貼り付けました。

Zombie Objects を有効にして、リリースされたオブジェクトへの呼び出しであるかどうかを確認し、クラッシュしたときのデバッグ ウィンドウのスクリーンショットを添付してみました。

ちなみに、「再開」を押すと、アプリは引き続き正常に機能します..

編集:これは最初です。設定したグローバル ブレークポイントがその行で停止し、[UIView animateWithDuration:0.2...これが出力コードです (今回はハード クラッシュしました)。

XYZ(14098,0xac3eaa28) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug 2013-02-23 13:19:36.653 XYZ[14098:c07] *** Terminating app due to uncaught exception 'NSMallocException', reason: '*** -[NSObject allocWithZone:]: attempt to allocate object of class 'UIViewAnimationState' failed'
*** First throw call stack: (0x1cf3012 0x17e8e7e 0x1d7e1a4 0x17fca6b 0x17fca55 0x3acceb 0x3baeec 0x3bb1a7 0x37785 0x3badf6 0x3add66 0x3adf04 0x10fc7d8 0x196d014 0x195d7d5 0x1c99af5 0x1c98f44 0x1c98e1b 0x28f17e3 0x28f1668 0x36fffc 0x28fd 0x2825) libc++abi.dylib: terminate called throwing an exception

- (void)startAnimating
{   
    _isAnimating = YES;
    float rotationAngle = 360.0 / 3;
    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^
    {
        self.marks.transform = CGAffineTransformRotate(self.marks.transform,
                                                       ((rotationAngle + 10) * (M_PI / 180.0)));
//        self.marks.transform = CGAffineTransformMakeRotation((rotationAngle + 10) * (M_PI / 180.0));
    }
                     completion:^(BOOL finished)
    {
        [UIView animateWithDuration:0.2
                              delay:0.0
                            options:UIViewAnimationOptionCurveEaseInOut
                         animations:^
        {
            self.marks.transform = CGAffineTransformRotate(self.marks.transform,
                                                           -10 * (M_PI / 180.0));
//            self.marks.transform = CGAffineTransformMakeRotation(-10 * (M_PI / 180.0));
        }
                         completion:^(BOOL finished)
        {
            self.marks.transform = CGAffineTransformIdentity;
            [self startAnimating];
        }];
    }];
}

正常にクラッシュしたときのスクリーンショット:

NSZombieObjects を無効にしたスクリーンショット

NSZombieObjects が有効になっているときのスクリーンショット:

NSZombieObjects を有効にしたスクリーンショット

4

1 に答える 1

1

2 番目のアニメーションの完了ブロックは、startAnimating を再帰的に呼び出しています。それが問題の原因だと思います。代わりにループを使用するか、繰り返しアニメーションを作成する必要があります。

于 2013-02-23T05:50:38.083 に答える