简体   繁体   English

同一字符串在iPad3和iPad mini上的显示方式不同

[英]The same string displays differently on iPad3 and iPad mini

I found a weird thing that Occasionally the same UITextView displays differently on iPad3 and iPad mini2 just like photos below. 我发现奇怪的事情是,有时相同的UITextView在iPad3和iPad mini2上的显示方式不同,如下图所示。 (It is OK on iPad3 but not OK on iPad mini2) (在iPad3上可以,但在iPad mini2上不能。)

Update: My iPad3 is IOS6 and iPad mini2 is IOS7. 更新:我的iPad3是IOS6,而iPad mini2是IOS7。 Now the problem is the same UITextView display differently by IOS version. 现在的问题是,相同的UITextView在IOS版本上的显示方式有所不同。 Finally I solved it. 终于我解决了。 The reason is the sentence is "The\\U00a0earth\\U00a0revolves\\U00a0around\\U00a0the\\U00a0sun." 原因是该句子是“ \\ U00a0earth \\ U00a0revolves \\ U00a0around \\ U00a0the \\ U00a0sun”。 not "The earth revolves around the sun." 不是“地球围绕太阳旋转”。 I should use half-width white space not full-width white space. 我应该使用半角空格而不是全角空格。

iPad3的

iPad mini2

I do not know why because I think iPad3 and iPad mini2 has the same screen resolution. 我不知道为什么,因为我认为iPad3和iPad mini2具有相同的屏幕分辨率。 Does any body can help? 有身体可以帮忙吗? thanks. 谢谢。

尝试在NSLineBreakByWordWrapping上将lineBreakMode设置为NSLineBreakByWordWrapping吗?

The property lineBreakMode is not directly available in a UITextView and maybe not. 属性lineBreakModeUITextView不是直接可用的,也许不是。

I recommend you to use a UILabel with 2 lines and here the property lineBreakMode is available by code or in the storyboard : 我建议您使用带有2行的UILabel ,在这里属性lineBreakMode可通过代码或在故事板中使用:

在此处输入图片说明

Hope that will help 希望会有所帮助

Try explicitly setting this and check. 尝试显式设置并检查。 But by default it is NSLineBreakByCharWrapping only. 但默认情况下,它仅是NSLineBreakByCharWrapping。

  textView.textContainer.lineBreakMode = NSLineBreakByCharWrapping;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM