UITableViewAutomaticDimension返回-1 [英] UITableViewAutomaticDimension return -1

查看:292
本文介绍了UITableViewAutomaticDimension返回-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我制作tableviewcontroller类,我想动态获取单元格高度,所以我使用UITableViewAutomaticDimension但它总是返回-1。

Hi I make tableviewcontroller class and I want to get cell height dynamicly so i use UITableViewAutomaticDimension but it always return me -1.

    tableView.rowHeight = UITableViewAutomaticDimension
    println("\(tableView.rowHeight)")
    tableView.estimatedRowHeight = 44

当我做tableView.rowHeight = 44时,一切都很好。我的超类是UIViewController。

when I do tableView.rowHeight = 44 everything works great. My superclass is UIViewController.

推荐答案

您只能使用 UITableViewAutomaticDimension 作为页脚/ header height,仅当你实现时:

You can only use UITableViewAutomaticDimension for footer/header height and only if you implement:

- tableView:titleForHeaderInSection:

如果您正在实施:

- tableView:viewForHeaderInSection:

它不起作用。 UITableViewAutomaticDimension 不用于设置行高。使用 rowHeight 并指定您的值或实现:

it will not work. UITableViewAutomaticDimension is not intended to be used to set the row height. Use rowHeight and specify your value or implement:

- tableView:heightForRowAtIndexPath:

这篇关于UITableViewAutomaticDimension返回-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆