简体   繁体   English

iOS8中的多行标签

[英]Multiline label in iOS8

I have updated my device iOS to iOS 8 and now multiline label is not working. 我已将设备iOS更新为iOS 8,但多行标签无法正常工作。 Its displaying very weird screen shot attached. 它显示了非常奇怪的屏幕快照。

So please can you suggest me the solution. 因此,请您为我提供解决方案。

I already set Number of lines =0 and it was working perfect in ios 7. Not using Autolayout and story board. 我已经将行数设置为= 0,并且在ios 7中运行良好。不使用自动布局和故事板。

多行标签

This code help you.It works fine me.Edit your code according to need 这段代码对您有帮助。我可以正常工作。根据需要编辑代码

 UILabel *problem = [[UILabel alloc] initWithFrame:CGRectMake(40, 100, 200, 100)];
    problem.lineBreakMode=NSLineBreakByWordWrapping;
    problem.text=@"Please use this code it may help you it works fine for me";
    problem.numberOfLines=0;
  [self.view addSubview:problem];

Strangely enough, this fix doesn't work if you don't use all of it: 奇怪的是,如果您不全部使用此修复程序将不起作用:

  1. Set the line break mode to word wrapping (if that's the affect you want). 将换行模式设置为自动换行(如果这是您想要的效果)。
  2. Set the number of lines to 0 (I had it set to 2 and it still didn't work). 将行数设置为0(我将其设置为2,但仍然不起作用)。

Not sure if something changed here with the introduction with iOS 8 but my previous code (just setting the number of lines to 2) was working great on iOS 7. 不确定iOS 8的引入是否对这里有所更改,但是我以前的代码(仅将行数设置为2)在iOS 7上是否运行良好。

Anyone else face a similar issue? 还有其他人遇到类似的问题吗?

您是否使用自定义字体?尝试更改字体。

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

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