iOS之自动调节输入文本框的高度
1 //自动调节输入文本框的高度 2 3 - (void)textViewDidChange:(UITableView *)textView{ 4 5 float height; 6 7 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { 8 9 CGRect textFrame = [[self.textView layoutManager] usedRectForTextContainer:[self.textView textContainer]]; 10 11 height = textFrame.size.height; 12 13 } 14 15 else{ 16 17 height = self.textView.contentSize.height; 18 19 } 20 21 self.textView.frame = CGRectMake(self.textView.frame.origin.x, self.textView.frame.origin.y, self.textView.frame.size.width, height); 22 23 } 24 25