我有一些代碼嘗試呈現圖形上下文中的png。該代碼在所有模擬器中都能正常工作,並且在iPad Air上運行良好。但是,當我在iPad Mini或iPad的一個運行它,我看到下面的崩潰運行時,它同時迷上了Xcode的:在drawAtPoint期間崩潰,代碼在iPad Air,iPad模擬器上運行,在iPad 1和iPad mini上崩潰
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上處理能力有限還是內存有限?任何想法如何解決?
謝謝!
- 戴夫
圖像有多大? –
什麼說調試器? – Larme
圖像是3680x3464,大約半個兆文件大小。這似乎不是非常巨大,但我會嘗試降低分辨率,看看是否有幫助。如果它與內存相關,那麼不幸的是模擬器無法模擬實際設備的內存限制 - 這些內容在模擬器中更容易調試! – Dave