ios中cell中有个textview,怎么在输入时计算cell高度
1个回答
展开全部
在tableviewcell中写
if (_recruitModel.recuritDetail.length) {
CGSize textSize=[_recruitModel.recuritDetail boundingRectWithfont:[UIFont systemFontOfSize:15] maxTextSize:CGSizeMake(__gScreenWidth-110, 20000)];
//textViewFrame.size.height=textSize.height+30;
textViewFrame.size.height= textSize.height<24?44:textSize.height+20;
textView.text= _recruitModel.recuritDetail;
}else {
textView.placeholder=model.infoPlaceHolder;
textViewFrame.size.height=44;
textView.text=@"";
}
nameLable.text=lHHSoft(@"k_job_PositionDetail");
textView.frame=textViewFrame;
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (_recruitModel.recruitAddress.length) {
CGSize textSize=[_recruitModel.recruitAddress boundingRectWithfont:[UIFont systemFontOfSize:15] maxTextSize:CGSizeMake(__gScreenWidth-110, 20000)];
return textSize.height<24?44:textSize.height+25;
}else {
return 44;
}
}
if (_recruitModel.recuritDetail.length) {
CGSize textSize=[_recruitModel.recuritDetail boundingRectWithfont:[UIFont systemFontOfSize:15] maxTextSize:CGSizeMake(__gScreenWidth-110, 20000)];
//textViewFrame.size.height=textSize.height+30;
textViewFrame.size.height= textSize.height<24?44:textSize.height+20;
textView.text= _recruitModel.recuritDetail;
}else {
textView.placeholder=model.infoPlaceHolder;
textViewFrame.size.height=44;
textView.text=@"";
}
nameLable.text=lHHSoft(@"k_job_PositionDetail");
textView.frame=textViewFrame;
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (_recruitModel.recruitAddress.length) {
CGSize textSize=[_recruitModel.recruitAddress boundingRectWithfont:[UIFont systemFontOfSize:15] maxTextSize:CGSizeMake(__gScreenWidth-110, 20000)];
return textSize.height<24?44:textSize.height+25;
}else {
return 44;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询