• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - UIAnimation 导致 XCode 在一段时间后崩溃

[复制链接]
菜鸟教程小白 发表于 2022-12-12 09:05:26 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我的应用程序在闲置 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];
        }];
    }];
}

正常崩溃时的截图:

Screenshot with NSZombieObjects disabled

NSZombieObjects 开启时的截图:

Screenshot with NSZombieObjects enabled



Best Answer-推荐答案


第二个动画的完成 block 递归调用 startAnimating。我认为这是问题的原因。您应该改用循环或创建重复动画。

关于iphone - UIAnimation 导致 XCode 在一段时间后崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15036257/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap