空格编码导致UILabel word warp失效

从windows发过来的文件文件中,如果直接复制到代码或者xib中会导致UILabel换行出现问题,原因是windows的空格编码方式和mac不同导致mac无法识别。可以全文替换一下解决。

The problem is that the whitespaces in the Strings that come from the server and are stored in the objects are Unicode Non-Breaking Spaces (U+00A0). When these Strings are assigned to the UILabel
text
property, Non-Breaking Spaces are not considered as word separators.
To solve this problem, I replace the occurrences of U+00A0 characters with common Unicode whitespace (U+0020), using String
's method stringByReplacingOccurrencesOfString("\u{00A0}", withString: "\u{0020}")
.

你可能感兴趣的:(空格编码导致UILabel word warp失效)