一、textview 高度自適應(yīng)
注意textfd.scrollEnabled = NO;
1.-(void)textViewDidChange:(UITextView *)textView
{//根據(jù)字長度判斷是否隱藏占位符Label
self.placehoderL.hidden = (textView.text.length > 0);
CGRect frame = textView.frame;
CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
CGSize size = [textView sizeThatFits:constraintSize];
//這里為了把 高度傳出去 做一個(gè)處理 ?比如夫類的空間適應(yīng)高度,最好傳出去之前做一個(gè)判斷 ?換行才進(jìn)行 傳出操作
self.sizeBlock(size.height);
}
2、在使用的地方
_inputV1.sizeBlock = ^(CGFloat height){
weakSelf.inputV1.height = height;
weakSelf.inputV1.textfd.frame = CGRectMake(0,0, SCreenWIDTH-115-20, height);
cell1H = height+10;//cell1H 代表的是單元格的高度
//下面兩句 重新載入高度 ?不刷新視圖
[tableView beginUpdates];
[tableView endUpdates];
};