一些注意事项:使用Xcode 4.6,目标是iOS6,完全ARC,在新iPad上测试.
任何帮助都将非常感谢!!
我删除了一些崩溃日志和控制台日志以缩短这篇文章!对它的长度表示歉意!
要应用于pdf创建的字符串的方法:
- (CFMutableAttributedStringRef) CreateAttributedString:(int*) dateLength TitleLength:(int*) TitleLength{ NSLog(@"Current EntryIndex: %d",_entryIndex); NSLog(@"Current Entry: %@",_currentEntry); // current entry is set from the parent vIEw controller via PrepareForSegue NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MMMM dd,yyyy,h:mm aaa"]; Nsstring * dateString = [dateFormatter stringFromDate:_currentEntry.created]; *dateLength = [dateString length]; NSLog(@"DateString: %@",dateString); NSLog(@"2nd DateLength: %d",*dateLength); Nsstring *Title = _entryTitle; *TitleLength = [Title length]; Nsstring *bodyString = _entryText; Nsstring *contentString = [Nsstring stringWithFormat:@"%@\n\n%@\n%@",dateString,Title,bodyString]; NSLog(@"TitleString: %@",Title); NSLog(@"BodyString: %@",bodyString); NSLog(@"TitleLength: %d",*TitleLength); CFStringRef string = (__brIDge CFStringRef)contentString; CFMutableAttributedStringRef attributedContentString CFAttributedStringCreateMutable(kcfAllocatorDefault,0); CFAttributedStringReplaceString (attributedContentString,CFRangeMake(0,0),string); return attributedContentString; } - (voID) SetTextFontname:(int)dateLength TitleLength:(int)TitleLength forAttributedString:(CFMutableAttributedStringRef) text{ //date CTFontDescriptorRef dateFontDescriptor = CTFontDescriptorCreateWithnameAndSize((__brIDge CFStringRef)_entryDateTimeFontname,_entryDateTimeFontSize); CTFontRef dateFont = CTFontCreateWithFontDescriptor(dateFontDescriptor,_entryDateTimeFontSize,NulL); NSLog(@"Font entryDateTimeFontSize,line 329: %d",_entryDateTimeFontSize); NSLog(@"DateFontDescriptor,line 329: %@",dateFontDescriptor); CFAttributedStringSetAttribute(text,dateLength),kCTFontAttributename,dateFont); NSLog(@"DateLength... before crash: %d",dateLength); NSLog(@"DateLength... crashing: %d",dateLength); CFAttributedStringSetAttribute(text,// this is line 341... kCTForegroundcolorAttributename,_entryDateTimecolor.CGcolor); NSLog(@"Date length for line 332: %d",dateLength); NSLog(@"Text for line 332: %@",text); NSLog(@"Font name... Font attributes line 332: %@",dateFont); NSLog(@"Date length for line 333: %d",dateLength); NSLog(@"Text for line 333: %@",text); NSLog(@"Date color for line 333: %@",_entryDateTimecolor.CGcolor); CFRelease(dateFontDescriptor); CFRelease(dateFont); //Title CTTextAlignment alignment = kCTCenterTextAlignment; CTParagraphStyleSetting _settings[] = {{kCTParagraphStyleSpecifIErAlignment,sizeof(alignment),&alignment}}; CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(_settings,sizeof(_settings) / sizeof(_settings[0])); CFAttributedStringSetAttribute(text,CFRangeMake(dateLength,dateLength + TitleLength),kCTParagraphStyleAttributename,paragraphStyle); CTFontDescriptorRef TitleFontDescriptor = CTFontDescriptorCreateWithnameAndSize((__brIDge CFStringRef)_entryTitleFontname,_entryTitleFontSize); CTFontRef TitleFont = CTFontCreateWithFontDescriptor(TitleFontDescriptor,_entryTitleFontSize,NulL); NSLog(@"TitleFontDescriptor: %@",TitleFontDescriptor); CFAttributedStringSetAttribute(text,TitleFont); CFAttributedStringSetAttribute(text,kCTForegroundcolorAttributename,_entryTitlecolor.CGcolor); NSLog(@"Titlecolor: %@",_entryTitlecolor); NSLog(@"Titlecolor: %@",_entryTitlecolor.CGcolor); CFRelease(TitleFontDescriptor); CFRelease(TitleFont); //content CTFontDescriptorRef FontDescriptor = CTFontDescriptorCreateWithnameAndSize((__brIDge CFStringRef)_entryTextFontname,_entryTextFontSize); CTFontRef Font = CTFontCreateWithFontDescriptor(FontDescriptor,_entryTextFontSize,NulL); CFAttributedStringSetAttribute(text,CFRangeMake(dateLength + TitleLength+2,CFAttributedStringGetLength(text) - dateLength - TitleLength - 2),Font); CFAttributedStringSetAttribute(text,_entryTextcolor.CGcolor); CFRelease(FontDescriptor); CFRelease(Font);}
崩溃日志:
IncIDent IDentifIEr: D5D15E15-8A4C-4850-B751-9F1D546F1F71CrashReporter Key: 54bfdcf0248d463bc97ac986b7553405b3b0f8b9HarDWare Model: iPad3,4Process: tabletJournal [9876]Path: /var/mobile/Applications/109DCB8E-22D1-45E4-A347- 1B1F211F9044/tabletJournal.app/tabletJournalIDentifIEr: tabletJournalVersion: ??? (???)Code Type: ARM (Native)Parent Process: launchd [1]Date/Time: 2013-03-20 15:42:11.412 +0100OS Version: iOS 6.1.2 (10B146)Report Version: 104Exception Type: EXC_BREAKPOINT (SIGTRAP)Exception Codes: 0x0000000000000001,0x000000000000defeCrashed Thread: 0Thread 0 name: dispatch queue: com.apple.main-threadThread 0 Crashed:0 CoreFoundation 0x3272b4e0 0x32693000 + 6238401 CoreFoundation 0x3271bc2c 0x32693000 + 5601722 CoreFoundation 0x3277043c 0x32693000 + 9063003 CoreFoundation 0x32697b4e 0x32693000 + 192784 CoreFoundation 0x32705e5e 0x32693000 + 4706225 tabletJournal 0x0005f3d8 -[ExportVIEw SetTextFontname:TitleLength:forAttributedString:] (ExportVIEw.m:341)6 tabletJournal 0x0005ed58 -[ExportVIEw saveJournalTopdf:andname:] (ExportVIEw.m:196)7 tabletJournal 0x0005ec8a -[ExportVIEw pdfbuttonTapped:] (ExportVIEw.m:179)8 UIKit 0x3464f082 0x34561000 + 9749789 UIKit 0x3464f036 0x34561000 + 97490210 UIKit 0x3464f010 0x34561000 + 97486411 UIKit 0x3464e8c6 0x34561000 + 97299812 UIKit 0x3464edb4 0x34561000 + 97426013 UIKit 0x345775f4 0x34561000 + 9163614 UIKit 0x345648dc 0x34561000 + 1455615 UIKit 0x345641ea 0x34561000 + 1277816 GraphiCSServices 0x362575f4 0x36251000 + 2610017 GraphiCSServices 0x36257222 0x36251000 + 2512218 CoreFoundation 0x3272a3e4 0x32693000 + 61949219 CoreFoundation 0x3272a386 0x32693000 + 61939820 CoreFoundation 0x3272920a 0x32693000 + 61492221 CoreFoundation 0x3269c238 0x32693000 + 3743222 CoreFoundation 0x3269c0c4 0x32693000 + 3706023 GraphiCSServices 0x36256336 0x36251000 + 2130224 UIKit 0x345b82b4 0x34561000 + 35704425 tabletJournal 0x0002e35a main (main.m:22)26 libdyld.dylib 0x3aa02b1c 0x3aa01000 + 6940Thread 0 crashed with ARM Thread State (32-bit): r0: 0x3ac440f0 r1: 0x00000000 r2: 0x00001200 r3: 0x3ac2ce44 r4: 0x00000000 r5: 0x1ea52580 r6: 0x3272b4d9 r7: 0x2fdd26c4 r8: 0x3ac47940 r9: 0x00000012 r10: 0x3acacd88 r11: 0x1ea52580 ip: 0x00010201 sp: 0x2fdd26c0 lr: 0x3271bc2f pc: 0x3272b4e0 cpsr: 0xa0000030
控制台日志…重要部分:
Mar 20 15:50:54 marcs-iPad tabletJournal[9947] <Warning>: SettingsModel,entrIEs: ("<JournalEntry: 0x1e296310>","<JournalEntry: 0x1e24be00>")Mar 20 15:50:54 marcs-iPad tabletJournal[9947] <Warning>: Export LoadingMar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: Current EntryIndex: 1Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: Current Entry: <JournalEntry: 0x1e296310>Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: DateString: marzo 20,2013,3:41 PMMar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: 2nd DateLength: 23Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: TitleString: Test2Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: BodyString: I’m here in the Istanbul airport again,for another 5-hour layover! Plane is suppose to take off at 2:50 pm! Next time,I’m going to make sure my layovers are not more than 2 hours. That’ll leave room for delays. I ate a small pizza at this “Italian” diner. It was actually pretty good. Later,I’ll have to compare it with real Italian pizza. I’m dead tired. Gotta get some caffeine! Got the caffeine! Yow! I should wake up in a few minutes! There are posters of Italia here and I’ve found a couple of places I’d like to see. Lago D’Orta di PIEmonte,galleria Borghese di Lazio- Roma,Pisa.Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: TitleLength: 5Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: Font entryDateTimeFontSize,line 329: 13Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: DateFontDescriptor,line 329: CTFontDescriptor <attributes: <CFBasicHash 0x1d518f50 [0x3ac440f0]>{type = mutable dict,count = 2,entrIEs =>1 : <CFString 0x3acad758 [0x3ac440f0]>{contents = "NSFontNameattribute"} = <CFString 0x1e07a880 [0x3ac440f0]>{contents = "copperplate"}2 : <CFString 0x3acad8c8 [0x3ac440f0]>{contents = "NSFontSizeAttribute"} = <CFNumber 0x1d5cb1d0 [0x3ac440f0]>{value = +13.0000000000,type = kcfNumberfloat32Type}}>Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: DateLength... before crash: 23Mar 20 15:50:55 marcs-iPad tabletJournal[9947] <Warning>: DateLength... crashing: 23Mar 20 15:50:56 marcs-iPad ReportCrash[9951] <Notice>: Formulating crash report for process tabletJournal[9947]Mar 20 15:50:56 marcs-iPad com.apple.launchd[1] (UIKitApplication:com.creativeappgroup.tabletJournalTM[0xe437][9947]) <Warning>: (UIKitApplication:com.creativeappgroup.tabletJournalTM[0xe437]) Job appears to have crashed: Trace/BPT trap: 5Mar 20 15:50:56 marcs-iPad ReportCrash[9951] <Error>: libmobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionaryMar 20 15:50:56 marcs-iPad backboardd[25] <Warning>: Application 'UIKitApplication:com.creativeappgroup.tabletJournalTM[0xe437]' exited abnormally with signal 5: Trace/BPT trap: 5Mar 20 15:50:56 marcs-iPad ReportCrash[9951] <Notice>: Saved crashreport to /var/mobile/library/Logs/CrashReporter/tabletJournal_2013-03-20-155055_marcs-iPad.pList using uID: 0 gID: 0,synthetic_euID: 501 egID: 0解决方法 事实证明,libmodileGestalt与崩溃没有任何关系.通过Apple论坛上的提示发现CGcolor可能是零.在实际调用之前隔离并安装日志语句之后,确实如此.实际上,所有的颜色……文本,标题和日期都是NulL.所以,我通过在create pdf方法中安装test和apply语句来解决崩溃问题.现在……找出为什么颜色没有被传递过来! 总结
以上是内存溢出为你收集整理的ios6 – libMobileGestalt copySystemVersionDictionaryValue:无法从系统版本字典中查找ReleaseType全部内容,希望文章能够帮你解决ios6 – libMobileGestalt copySystemVersionDictionaryValue:无法从系统版本字典中查找ReleaseType所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)