1)我想在TextView中启用ScrollView。当TextView高度增加时。
2)当我输入完整行后按Enter键我正在输入的内容正在显示。但是当我按下输入后只输入2或3个字母时,我输入的内容未显示。按下回车后显示
-(void)viewDidLoad
{
UITextView *txtView=[[UITextView alloc]init];
txtView.frame = CGRectMake(60, 100, 350, 154);
txtView.backgroundColor=[UIColor whiteColor];
txtView.font=[UIFont fontWithName:Nil size:30];/*Font size*/
txtView.delegate=self;
txtView.scrollEnabled=YES;
[self.view addSubview:txtView];
}
-(void)textViewDidChange:(UITextView *)textView
{
if(textView.contentSize.height>textView.frame.size.height)
{
CGRect frame = txtView.frame;
frame.size.height = textView.contentSize.height+90;
textView.frame = frame;
textView.scrollEnabled=YES;
}
textView.scrollEnabled=YES;
}
答案 0 :(得分:0)
if(textView.contentSize.height > textView.frame.size.height)
{
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height + 90;
textView.frame = frame;
textView.scrollEnabled = YES;
[textView setContentSize:CGSizeMake(0, textView.frame.size.height + 1)];
}