在drawAtPoint期间崩溃,代码适用于iPad Air,iPad模拟器,iPad 1和iPad mini上的崩溃

时间:2014-04-18 20:40:20

标签: ios ipad crash uiimage

我有一些代码试图将png渲染到图形上下文。该代码在所有模拟器中都能正常工作,并且可以在iPad Air上正常运行。但是当我在iPad mini或iPad上运行它时,我在连接到xCode时运行它时会看到以下崩溃:

ImageIO`ImageIO_ABGR_TO_ARGB_8Bit: 0x36f27c70: push {r4, r5, r6, r7, lr} 0x36f27c72: add r7, sp, #0xc 0x36f27c74: push.w {r8, r10, r11} 0x36f27c78: ldr r1, [r0] 0x36f27c7a: ldr r2, [r0, #0xc] 0x36f27c7c: cmp.w r2, r1, lsl #2 0x36f27c80: blo 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c82: ldr r3, [r0, #0x18] 0x36f27c84: lsls r2, r1, #0x2 0x36f27c86: cmp r3, r2 0x36f27c88: blo 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c8a: ldr r2, [r0, #0x4] 0x36f27c8c: cmp r2, #0x0 0x36f27c8e: beq 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c90: bic lr, r1, #0x7 0x36f27c94: ldr r3, [r0, #0x8] 0x36f27c96: ldr.w r12, [r0, #20] 0x36f27c9a: sub.w r4, r1, lr 0x36f27c9e: asrs r5, r1, #0x3 0x36f27ca0: mov r6, r12 0x36f27ca2: mov r8, r3 0x36f27ca4: cbz r5, 0x36f27cbe ; ImageIO_ABGR_TO_ARGB_8Bit + 78 0x36f27ca6: mov r8, r3 0x36f27ca8: mov r9, r5 0x36f27caa: mov r6, r12 0x36f27cac: vld4.8 {d0, d1, d2, d3}, [r8]! 0x36f27cb0: vswp d0, d2 0x36f27cb4: vst4.8 {d0, d1, d2, d3}, [r6]! <<--- crash on this line 0x36f27cb8: subs.w r9, r9, #0x1

以下是生成崩溃的代码:

NSString* imgFile = @"ShotZones.png";
UIImage* img = [UIImage imageNamed:imgFile];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
float scaleShotZoneFeetToPixels = img.size.width / shotZoneCourtSizeInFeet.x;
CGRect courtRect = {{0, 0}, img.size};
CGFloat scaleFactor = screenWidth / courtRect.size.width;
UIGraphicsBeginImageContext(img.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scaleFactor, scaleFactor);
[img drawAtPoint: courtRect.origin];

在调用drawAtPoint时崩溃(在一个单独的线程中)。单步执行代码时,所有计算值都与在xCode模拟器中运行时相同,UIImage不为空等等。这是由于iPad处理能力有限还是内存有限?有关如何修复的想法吗?

谢谢!

  • 戴夫

1 个答案:

答案 0 :(得分:0)

好的,我得到了它的工作。这是图像的分辨率。我把它减少了4倍,现在它可以工作了。我假设设备内存不足。如果有人知道如何配置模拟器来模拟iPad 1或迷你的内存容量,我会很感激。我希望能够尽可能在模拟器中进行调试/测试!