我有一个简单的textView动态填充数据。我想在填充数据后调整textview的高度,这样我就看不到垂直滚动,也没有剪切文本。我有两个像爱好这样的文本字段感兴趣和相关的标签,如爱好和感兴趣。昨天也发布了这个Query.But我没有得到任何解决方案。我想根据爱好textview自动显示感兴趣的标签和感兴趣的textview。请帮助我任何人。我昨天开始讨论这个问题请任何人给我指导。提前谢谢。
tViewhobbies=[[UITextView alloc]initWithFrame:CGRectMake(10, 330, 300, 60)];
tViewhobbies.backgroundColor=[UIColor clearColor];
tViewhobbies.layer.cornerRadius=5;
[tViewhobbies setFont:[UIFont systemFontOfSize:13.0]];
[tViewhobbies setUserInteractionEnabled:NO];
tViewhobbies.font=[UIFont systemFontOfSize:16.0];
tViewhobbies.backgroundColor=[UIColor colorWithRed:0.662745 green:0.662745 blue:0.662745 alpha:0.5];
tViewhobbies.delegate=self;
tViewhobbies.scrollEnabled=YES;
[scrollView addSubview:tViewhobbies];
lblInterests = [[UILabel alloc]initWithFrame:CGRectMake(10, 370, 300, 20)];
lblInterests.text=@"Interests";
lblInterests.font=[UIFont systemFontOfSize:16.0];
lblInterests.textColor=[UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1];
[scrollView addSubview:lblInterests];
tViewInterests=[[UITextView alloc]initWithFrame:CGRectMake(10, 390, 300, 60)];
tViewInterests.backgroundColor=[UIColor clearColor];
[tViewInterests setFont:[UIFont systemFontOfSize:13.0]];
[tViewInterests setUserInteractionEnabled:NO];
tViewInterests.font=[UIFont systemFontOfSize:16.0];
tViewInterests.backgroundColor=[UIColor colorWithRed:0.662745 green:0.662745 blue:0.662745 alpha:0.5];
tViewInterests.delegate=self;
tViewInterests.scrollEnabled=YES;
[scrollView addSubview:tViewInterests];
答案 0 :(得分:0)
你只需要设置
[tViewInterests sizeToFit];
[tViewInterests layoutIfNeeded];