1

我有一个 UILabel,它应该显示文本它将是多长时间。所以 UILineBreakModeWordWrap 的概念已经消失,但它对我不起作用..如果文本不适合该行,那么它应该自动出现在下一个线

UILabel *lblMyLable = [[[UILabel alloc] initWithFrame:CGRectMake(10,118, 600, 40)]autorelease];
    lblMyLable.lineBreakMode = UILineBreakModeWordWrap;
    lblMyLable.numberOfLines = 0;//Dynamic
    lblMyLable.tag=1301;
    lblMyLable.backgroundColor = [UIColor clearColor];
    lblMyLable.text = [NSString stringwithformat:@"%@ %@ %@ %@ %@ %@",id,name,address,city,state,country];
    [self.view addSubview:lblMyLable];

但是在这里显示 id ,名称和地址后,剩余部分被剪切了..我看不到它..我正在搜索这样一种方式,如果不适合一行,那么它应该从停止的地方自动跳转到下一行在第一行。我该怎么做?

4

3 回答 3

5
NSString *str = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sh";
NSString *str1 = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sh";
NSString *str2 = @"xyz";
NSString *str3 = @"xyz";
NSString *str4 = @"xyz";
NSString *str5 = @"xyz";
NSString *str6 = @"xyz";
NSString *str7 = @"xyz";   

UILabel *lblMyLable = [[UILabel alloc] initWithFrame:CGRectMake(10,10, 200, 40)];

lblMyLable.numberOfLines = 0;

lblMyLable.backgroundColor = [UIColor clearColor];

lblMyLable.text = [NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@,%@,%@",str,str1,str2,str3,str4,str5,str6,str7];

[lblMyLable sizeToFit];

[self.view addSubview:lblMyLable];
于 2012-10-17T06:21:28.563 回答
1

你的高度UILable太小,看不到线条

将高度设置为大于40

UILabel *lblMyLable = [[UILabel alloc] initWithFrame:CGRectMake(10,118, 600, 240)];
于 2012-10-17T06:19:28.513 回答
0

这将帮助你

lblMyLable.numberOfLines = 0;
lblMyLable.text = [NSString stringwithformat:@"%@ %@ %@ %@ %@ %@",id,name,address,city,state,country];
[lblMyLable sizeToFit];
于 2012-10-17T06:16:55.193 回答