//UILabel自动换行,自适应高度
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont systemFontOfSize:14]];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:0];
[self.view addSubview:label];
NSString *str = @"那些年错过的大雨 那些年错过的爱情 好想拥抱你 拥抱错过的勇气 曾经想征服全世界 到最后回首才发现 这世界滴滴点点全部都是你 那些年错过的大雨 那些年错过的爱情 好想告诉你 告诉你我没有忘记 那天晚上满天星星 平行时空下的约定 再一次相遇我会紧紧抱着你 紧紧抱着你";
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320,500) lineBreakMode:UILineBreakModeWordWrap];
[label setText:str];
[label setFrame:CGRectMake(0.0f, 20.0f, size.width, size.height)];
[label release];
//UITextView自动换行,自适应高度
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 150, 320, 240)];
textView.backgroundColor = [UIColor clearColor];
textView.text = str;
textView.scrollEnabled = YES;
textView.font = [UIFont systemFontOfSize:14];
textView.userInteractionEnabled = NO;
textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont systemFontOfSize:14]];
[label setLineBreakMode:UILineBreakModeWordWrap];
[label setNumberOfLines:0];
[self.view addSubview:label];
NSString *str = @"那些年错过的大雨 那些年错过的爱情 好想拥抱你 拥抱错过的勇气 曾经想征服全世界 到最后回首才发现 这世界滴滴点点全部都是你 那些年错过的大雨 那些年错过的爱情 好想告诉你 告诉你我没有忘记 那天晚上满天星星 平行时空下的约定 再一次相遇我会紧紧抱着你 紧紧抱着你";
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(320,500) lineBreakMode:UILineBreakModeWordWrap];
[label setText:str];
[label setFrame:CGRectMake(0.0f, 20.0f, size.width, size.height)];
[label release];
//UITextView自动换行,自适应高度
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 150, 320, 240)];
textView.backgroundColor = [UIColor clearColor];
textView.text = str;
textView.scrollEnabled = YES;
textView.font = [UIFont systemFontOfSize:14];
textView.userInteractionEnabled = NO;
textView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view addSubview:textView];