2

我有一个很长的字符串,如下所示...

[[sqrt(221)-10,-sqrt(221)-10],[11,11]],[[rootof([[474368400,237184200,-125944810200,258530778000],[1,0,-472,884,42215 ]])/(sqrt(221)*782707860000)+rootof([[409681800,9099248400,-99876110400,-1875803589000],[1,0,-472,884,42215]])/(sqrt(22100)*782707860 3,rootof([[[ -  3439170900,-5063826700,864180632700,9670592794500]],[1,0,-472,884,42215]) -4442729593500],[1,0,-472,884,42215]])/(sqrt(221)*782707860000)*3],[rootof([[474368400,237184200,-125944810200,258530778000],[1,0- 472,884,42215]])/(sqrt(221)*782707860000)*2+rootof([[409681800,9099248400,-99876110400,-1875803589000],[1,0,-472,884,42215]])/(sqrt )*782707860000)*4,rootof([[-3439170900,-50638826700,864180632700,9670592794500],[1,0,-472,884,42215]])/(sqrt(221)*782707(860000)*2+rootof 1477010700,22974524100,-369910322100,-4442729593500],[1,0,-472,884,42215]])/(sqrt(221)*782707860000)*4]],[sqrt(sqrt(221)+15),sqrt(-sqrt(221)+15 )]

如何在 UILabel 中显示超过一行 (0) 的整个内容?

此外,虽然字符串中没有换行符(“\n”),但结果显示如下......

[[sqrt(221)-10,-sqrt(221)- 
10],[11,11]],[[rootof([[474368400,2
37184200,-
125944810200,258530778000],[1,
0,-
472,884, 42215]])/(sqrt(221)*78270

有什么帮助吗?

PS我可以上传图片但我不允许因为我是新用户...

4

7 回答 7

2
 textLabel.lineBreakMode = UILineBreakModeWordWrap;
 textLabel.numberOfLines = 0;
于 2012-06-27T11:49:11.140 回答
2

将 UILabel 设置为多行

MyLbl.numberOfLines = xxx;

如果您没有足够的空间来设置 UIlabel,那么还将 textView 设置为不可编辑的属性:

Mytxt = [[UITextView alloc]initWithFrame:CGRectMake(xx.0, x.0, xx.0,xx.0)];
Mytxt.transform = transform;
Mytxt.adjustsFontSizeToFitWidth = YES;
Mytxt.textColor = [UIColor blackColor];
Mytxt.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[Mytxt setFont:[UIFont fontWithName:@"Arial" size:xx.0]];
Mytxt.backgroundColor = [UIColor clearColor];
Mytxt.delegate = self;
Mytxt.userInteractionEnabled=YES;
Mytxt.editable=NO;

我希望你能得到答案。

于 2012-06-27T12:08:54.877 回答
0

如果您希望UILineBreakModeCharacterWrap您的文本沿多行均匀分布(因此它不会尝试在工作边界处中断),则需要。

于 2012-06-27T14:45:39.953 回答
0

您可以使用具有不可编辑模式的自动大小的 UITextView 而不是 UILabel (或)

CGSize labelSize = yourString sizeWithFont:cellFont     
constrainedToSize:CGSizeMake(190.0f, MAXFLOAT); lineBreakMode:UILineBreakModeWordWrap];

此标签大小将动态定义您可以分配给标签的标签高度

于 2012-06-27T11:50:21.857 回答
0
 try this code
    NSString *yourString = @"[[sqrt(221)-10,-sqrt(221)-10],[11,11]],[[rootof([[474368400,237184200,-125944810200,258530778000],[1,0,-472,884,42215]])/(sqrt(221)*782707860000)+rootof([[409681800,9099248400,-99876110400,-1875803589000],[1,0,-472,884,42215]])";
    UILabel *lblNameDesc=[[UILabel alloc] initWithFrame:CGRectMake(55, 10, 250, 21)];
    [lblNameDesc setNumberOfLines:0];
    lblNameDesc.text=yourString;

    [lblNameDesc setBackgroundColor:[UIColor clearColor]];
    [lblNameDesc setTextColor:[UIColor colorWithRed:64.0/255.0 green:64.0/255.0 blue:64.0/255.0 alpha:1.0f]];

    [self.view addSubview:lblNameDesc];
  //  [lblNameDesc release];
    [lblNameDesc sizeToFit];
于 2012-06-27T11:50:40.260 回答
0

假设你的字符串是。让您的喜爱和宽度随心所欲:-

NSString longString = @"dsjkghsdkjnfgvsdjgsl,v.........................";

CGSize maximumLabelSize = CGSizeMake(200,MAXFLOAT);

CGSize expectedLabelSize = [longString  sizeWithFont:[UIFont fontWithName:@"Aial-BoldMT" size:15.0] constrainedToSize:maximumLabelSize   
                              lineBreakMode:UILineBreakModeWordWrap];

UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, expectedLabelSize.height)];
myLabel.lineBreakMode = UILineBreakModeWordWrap;
myLabel.numberOfLines = 0; 
myLabel.text = longString ;

这可能会帮助你

于 2012-06-27T11:54:45.230 回答
0

尝试这个...

textLabel.lineBreakMode = YES;
 textLabel.numberOfLines = 10; // or many that you need...
于 2012-06-27T12:21:21.920 回答