tableVIEw.rowHeight = UItableVIEwautomaticDimensiontableVIEw.estimatedRowHeight = 44.0@H_403_1@细胞不做自动高度,它真的是真的 – 你不能在默认的样式细胞上使用它吗? @H_403_1@编辑: @H_403_1@人口简单
overrIDe func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr("Cell",forIndexPath: indexPath) let thisHelpArticle = helpObjects[indexPath.section] cell.textLabel!.text = thisHelpArticle.helpheadline cell.detailTextLabel!.text = thisHelpArticle.helpDescription return cell}UPDATE!
为了使默认单元格子标题自动调整单元格,您必须将两个标签的行数设置为0.否则它不起作用.奇怪的.
cell.textLabel?.numberOflines = 0cell.detailTextLabel?.numberOflines = 0@H_403_1@您可以自动调整默认的sytled单元格大小.在最简单的形式中,我有以下代码.这是自动调整默认样式字幕单元格的大小.
class VIEwController: UIVIEwController { @IBOutlet var tableVIEw: UItableVIEw! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() tableVIEw.dataSource = self tableVIEw.delegate = self tableVIEw.rowHeight = UItableVIEwautomaticDimension tableVIEw.estimatedRowHeight = 44 } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. }}extension VIEwController: UItableVIEwDataSource { func tableVIEw(tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { return 2 } func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr("Cell",forIndexPath: indexPath) let thisHelpArticle = "Lorem ipsum dolor sit amet,vel porttitor blandit,aliquam tristique vestibulum,enim vel eros fames ID,in gravida vestibulum gravida tempor,et vel libero sed mauris. Suspendisse ut placerat viverra dictum,ante ante vel ut vestibulum sollicitudin phasellus. Dictumst adipiscing adipiscing nisl,fusce ut. Ante wisi pellentesque,et aliquam rhoncus eget convallis quam voluptate,ut nec quis,soDales ullamcorper elementum pellentesque sagittis vitae,dolor justo fermentum amet risus. Eu placerat ultricIEs. Ipsum soDales,massa elit,in neque,sed penatibus gravida,cursus eget. Ut tincIDunt at eu,wisi dis vel penatibus eget,volutpat ligula vel tortor morbi feugiat,dui et eiusmod dis socIIS. Iaculis lorem molestIE laoreet sit,orci commodo,fusce vestibulum sAPIen,quisque egestas maecenas sed rem in nisl." cell.textLabel?.numberOflines = 0 cell.detailTextLabel?.numberOflines = 0 cell.textLabel!.text = thisHelpArticle cell.detailTextLabel!.text = thisHelpArticle return cell }}extension VIEwController: UItableVIEwDelegate {}总结
以上是内存溢出为你收集整理的swift – 默认UITableView Cell自动高度全部内容,希望文章能够帮你解决swift – 默认UITableView Cell自动高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)