
屏幕是一个登录屏幕.
>第一个单元格包含一些解释文本
>第二个是用于输入帐户名称的文本字段
>第三个是用于输入密码的安全文本字段
>第四个(也是最后一个)单元格包含登录按钮.键盘上的返回键提交表单或根据需要切换焦点
- (CGfloat)tableVIEw:(UItableVIEw *)tableVIEw heightForRowAtIndexPath:(NSIndexPath *)indexPath { int toppadding = 10; int bottompadding = 10; float landscapeWIDth = 400; float portraitWIDth = 300; UIFont *Font = [UIFont FontWithname:@"Arial" size:22]; //This is for first cell only if you want for all then remove below condition if (indexPath.row == 0) // for cell with dynamic height { Nsstring *strText = [[arrTexts objectAtIndex:indexPath.row]; // filling text in label if(landscape)//depends on orIEntation { CGSize maximumSize = CGSizeMake(landscapeWIDth,MAXfloat); // change wIDth and height to your requirement } else //protrait { CGSize maximumSize = CGSizeMake(portraitWIDth,MAXfloat); // change wIDth and height to your requirement } //dynamic height of string depending on given wIDth to fit CGSize textSize = CGSizeZero; if(SYstem_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") { NSMutableParagraphStyle *pstyle = [NSMutableParagraphStyle new]; pstyle.lineBreakMode = NSlineBreakByWorDWrapPing; textSize = [[strText boundingRectWithSize:CGSizeMake(wIDth,MAXfloat) options:NsstringDrawingUseslineFragmentOrigin attributes:@{NSFontAttributename :Font,NSParagraphStyleAttributename:[pstyle copy]} context:nil] size]; } else // < (iOS 7.0) { textSize = [strText sizeWithFont:Font constrainedToSize:maximumSize lineBreakMode:NSlineBreakByWorDWrapPing] } return (toppadding+textSize.height+bottompadding) // caculate on your bases as u have string height } else { // return height from the storyboard return [super tableVIEw:tableVIEw heightForRowAtIndexPath:indexPath]; } } 编辑:添加支持>和<在iOS 7.0中不推荐使用ios7和sizeWithFont方法
总结以上是内存溢出为你收集整理的ios – 带有包装标签的静态表格单元的动态高度?全部内容,希望文章能够帮你解决ios – 带有包装标签的静态表格单元的动态高度?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)