我在表格视图中分配了一个标签,但是标签中的文本在太长时不会换行到下一行。
我的代码如下:
UILabel *food_lbl=[[UILabel alloc]init];
foodspe = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults]valueForKey:@"food"]];
foodspe = [foodspe stringByReplacingOccurrencesOfString:@"(" withString:@""];
foodspe = [foodspe stringByReplacingOccurrencesOfString:@")" withString:@""];
foodspe = [foodspe stringByReplacingOccurrencesOfString:@"\n" withString:@""];
foodspe = [foodspe stringByReplacingOccurrencesOfString:@" " withString:@""];
food_lbl.text = foodspe;
food_lbl.numberOfLines=2;
food_lbl.lineBreakMode=UILineBreakModeWordWrap;
[food_lbl setFrame:CGRectMake(100, 0, 150, 100)];
[food_lbl setFont:[UIFont boldSystemFontOfSize:25.0f]];
[cell.contentView addSubview:header];
例如food_lbl
是paneer,panjabi,pasta,pizza,Puff,chocolates