自动调节输入文本框的高度

自动调节输入文本框的高度

//自动调节输入文本框的高度

- (void)textViewDidChange:(UITableView *)textView{

float height;

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

CGRect textFrame = [[self.textView layoutManager] usedRectForTextContainer:[self.textView textContainer]];

height = textFrame.size.height;

}

else{

height = self.textView.contentSize.height;

}

self.textView.frame = CGRectMake(self.textView.frame.origin.x, self.textView.frame.origin.y, self.textView.frame.size.width, height);

}

05-08 08:29