我正在使用以下代码将HTML转换为PDF。应用程序在10秒后崩溃或执行“renderInContext”12次或更多次
UIGraphicsBeginPDFContextToFile(self.filePath, CGRectZero, nil); //creating PDF
int i = 0;
for (; i < pages; i++)
{
if (pageHeight * (i+1) > height)
{
CGRect f = [myWebPage frame];
f.size.height -= (((i+1) * pageHeight) - height);
[myWebPage setFrame: f];
}
// Specify the size of the pdf page
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, width, pageHeight), nil);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
[[[myWebPage subviews] lastObject] setContentOffset:CGPointMake(0, pageHeight * i) animated:NO];
[myWebPage.layer renderInContext: currentContext];
NSLog(@"I = %d",i);
}
UIGraphicsEndPDFContext();
[[[myWebPage subviews] lastObject] setContentOffset:CGPointMake(0, 0) animated:NO];
[myWebPage setFrame:origframe];
但经过10秒或用于环路越来越坠毁I> = 12,
其在得到坠毁:
[myWebPage.layer renderInContext: currentContext];
我有试图 “CGContextRelease(currentContext);”也但它不工作..
我可以请知道为什么它崩溃,以及如何防止崩溃的应用程序。
控制台输出:
2013-06-06 10:15:26.179 app[8084:907] Width : 980.000000
2013-06-06 10:15:26.180 app[8084:907] NUMBER OF PAGES : 15
2013-06-06 10:15:26.382 app[8084:907] I = 0
2013-06-06 10:15:28.400 app[8084:907] I = 1
2013-06-06 10:15:28.903 app[8084:907] I = 2
2013-06-06 10:15:30.330 app[8084:907] I = 3
2013-06-06 10:15:31.524 app[8084:907] I = 4
2013-06-06 10:15:32.641 app[8084:907] I = 5
2013-06-06 10:15:33.470 app[8084:907] I = 6
2013-06-06 10:15:34.634 app[8084:907] I = 7
2013-06-06 10:15:35.791 app[8084:907] I = 8
2013-06-06 10:15:36.970 app[8084:907] I = 9
2013-06-06 10:15:38.108 app[8084:907] I = 10
2013-06-06 10:15:38.927 app[8084:907] I = 11
和应用程式得到坠毁在iPhone(在模拟器工作正常)
(修订版): 并且在其它情况下,其显示:
2013-06-06 11:17:33.023 app[8202:907] Width : 320.000000
2013-06-06 11:17:33.024 app[8202:907] NUMBER OF PAGES : 2
2013-06-06 11:17:38.200 app[8202:907] I = 0
2013-06-06 11:17:41.390 app[8202:907] I = 1
2013-06-06 11:17:44.028 app[8202:2103] void SendDelegateMessage(NSInvocation *): delegate (webView:didFinishLoadForFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
(lldb)
和
libsystem_kernel.dylib`mach_msg_trap:
0x3aa45e1c: mov r12, sp
0x3aa45e20: push {r4, r5, r6, r8}
0x3aa45e24: ldm r12, {r4, r5, r6}
0x3aa45e28: mvn r12, #30
0x3aa45e2c: svc #128
0x3aa45e30: pop {r4, r5, r6, r8} <=== Thread 1: singal SIGSTOP
0x3aa45e34: bx lr
请帮我解决..
什么是错误?哪一行代码是从哪里来的? – rmaddy
该应用程序正在崩溃.. – Raju
其获取崩溃在“[myWebPage.layer renderInContext:currentContext];”.. – Raju