These days we have encountered a hole in the height of the computed text, recorded here.
I started with the following code when calculating the height of a piece of text:
Cgsize Msgwh = [_msgmodel.msg boundingrectwithsize:cgsizemake (WBSCREENW-MSGX, maxfloat) options: Nsstringdrawinguseslinefragmentorigin attributes:@{nsfontattributename:[uifont fontWithName:@ "PingFang SC" size:13 ]} context:nil].size;
And then there's the following problem.
Exception Type: exc_crash (SIGABRT)
Exception codes:0x0000000000000000, 0x0000000000000000 by
Thread: 0 Last
Exception backtrace:
0 corefoundation 0x18546c2d8 __exceptionpreprocess + 132
1 LIBOBJC. A.dylib 0x1971380e4 Objc_exception_throw +
2 corefoundation 0x1853589c8-[__ Nsplaceholderdictionary InitWithObjects:forKeys:count:] + 420
3 corefoundation 0x1853587f8 +[ Nsdictionary DictionaryWithObjects:forKeys:count:] + 72
The following is a reference to this post
Http://stackoverflow.com/questions/13621084/boundingrectwithsize-for-nsattributedstring-returning-wrong-size
Change it to the following:
Nsdictionary *attributesdictionary = [nsdictionary dictionarywithobjectsandkeys:[uifont fontWithName:@ "PingFang SC" Size:13], Nsfontattributename,nil, Nsforegroundcolorattributename,nil];
Nsmutableattributedstring *string =[[nsmutableattributedstring alloc] initwithstring: _msgmodel.msg attributes: Attributesdictionary];
Cgsize Msgwh = [string Boundingrectwithsize:cgsizemake (Wbscreenw-msgx-wbspacing, Maxfloat) options: ( nsstringdrawinguseslinefragmentorigin| nsstringdrawingusesfontleading) Context:nil].size;
Then the program will not be crash, but in the version below IOS9 will appear the font display problem, the font becomes very small, and will affect other fields, in IOS9 above the version is all normal, the following found is [Uifont fontwithname:@ "Pingfang SC" SIZE:13] The reason for this font, Pingfang sc This font is IOS9.0.2, so there will be the problem in IOS8, which is why the beginning of the kind of writing will cause the program crashes, because in the IOS8 system, @{ Nsfontattributename:[uifont fontwithname:@ "Pingfang SC" size:13]} will cause crash, refer to http://www.tuicool.com/articles/ Y3EFAV7, and then it's normal to change the font to use the system font.
Later found that the individual mobile phone under the IOS9.3 and crash:
Exception Type: exc_crash (SIGABRT)
Exception codes:0x0000000000000000, 0x0000000000000000
Exception Note: exc_corpse_notify
triggered by Thread: 0
filtered syslog:
None found last
Exception BackTrace:
0 corefoundation 0x18357adb0 __exceptionpreprocess + 124
1 LIBOBJC. A.dylib 0x182bdff80 Objc_exception_throw +
2 corefoundation 0x18357acf8 +[nsexception raise: Format:] +
3 Foundation 0x183e698f0-[nsconcretemutableattributedstring initwithstring: Attributes:] + 136
Log says is nsmutableattributedstring *string =[[nsmutableattributedstring alloc] initwithstring: _msgmodel.msg attributes: Attributesdictionary]; The problem, and then I changed the way
nsdictionary *attributesdictionary = [Nsdictionary dictionarywithobjectsandkeys:[uifont
Systemfontofsize:13], Nsfontattributename,nil, Nsforegroundcolorattributename,nil]; Cgsize Msgwh = [_msgmodel.msg boundingrectwithsize:cgsizemake (WBSCREENW-MSGX, maxfloat) options:
Nsstringdrawinguseslinefragmentorigin attributes:attributesdictionary context:nil].size;