gpt4 book ai didi

ios - iPhone在后台播放图层动画时崩溃

转载 作者:行者123 更新时间:2023-11-29 13:40:38 24 4
gpt4 key购买 nike

我在修复讨厌的崩溃时遇到了问题。我无法弄清楚如何准确地重现它,但它只发生在应用程序退出后台后。我每 2 天以上就会遇到一次崩溃。

在 applicationDidBecomeActive: 中,我重新启动了一个每 0.4 秒触发一次的计时器。它调用:

- (void)rotate {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
self.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-[LocationModel instance].heading.magneticHeading));
[UIView commitAnimations];

}

在 RotateView 中还有 drawRect,如崩溃报告所示,其主体位于第 41 行。

- (void)drawRect:(CGRect)rect {

[img drawInRect:rect]; // line 41
}

img 是一个用 imageNamed: 加载并存储在 ivar 中的小型 UIImage。

有什么建议吗?我对崩溃报告没有什么经验。

谢谢!


崩溃报告:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x3001b482
Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x333a6c98 objc_msgSend + 16
1 MyApp 0x000259bc -[RotateView drawRect:] (RotateView.m:41)
2 UIKit 0x34f4a9fe -[UIView(CALayerDelegate) drawLayer:inContext:] + 258
3 QuartzCore 0x3058efa6 -[CALayer drawInContext:] + 86
4 QuartzCore 0x3058ed24 _ZL16backing_callbackP9CGContextPv + 32
5 QuartzCore 0x3058e776 CABackingStoreUpdate + 1226
6 QuartzCore 0x3058e178 -[CALayer _display] + 724
7 QuartzCore 0x3058de86 -[CALayer display] + 134
8 QuartzCore 0x30582706 CALayerDisplayIfNeeded + 178
9 QuartzCore 0x305821c6 CA::Context::commit_transaction(CA::Transaction*) + 214
10 QuartzCore 0x30581fd0 CA::Transaction::commit() + 184
11 QuartzCore 0x30580900 CA::Transaction::pop() + 120
12 QuartzCore 0x3058087e +[CATransaction commit] + 22
13 UIKit 0x35096bcc _UIWindowUpdateVisibleContextOrder + 136
14 UIKit 0x35096c60 +[UIWindow _prepareWindowsForAppResume] + 4
15 UIKit 0x3508f3de -[UIApplication _handleApplicationResumeEvent:] + 66
16 UIKit 0x34f39e20 -[UIApplication handleEvent:withNewEvent:] + 2724
17 UIKit 0x34f3920e -[UIApplication sendEvent:] + 38
18 UIKit 0x34f38c4c _UIApplicationHandleEvent + 5084
19 GraphicsServices 0x35873e70 PurpleEventCallback + 660
20 GraphicsServices 0x35873efa PurpleEventSignalCallback + 10
21 CoreFoundation 0x36126a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
22 CoreFoundation 0x36128758 __CFRunLoopDoSources0 + 376
23 CoreFoundation 0x361294e4 __CFRunLoopRun + 224
24 CoreFoundation 0x360b9ebc CFRunLoopRunSpecific + 224
25 CoreFoundation 0x360b9dc4 CFRunLoopRunInMode + 52
26 GraphicsServices 0x35873418 GSEventRunModal + 108
27 GraphicsServices 0x358734c4 GSEventRun + 56
28 UIKit 0x34f63d62 -[UIApplication _run] + 398
29 UIKit 0x34f61800 UIApplicationMain + 664
30 MyApp 0x000026c4 main (main.m:14)
31 MyApp 0x0000266c start + 32

最佳答案

EXC_BAD_ACCESS 通常意味着您释放了一个对象,然后又调用了该对象。尝试启用 NSZombies 来找到它。有很多关于如何操作的教程。从这里开始 http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/

关于ios - iPhone在后台播放图层动画时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9286428/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com