1

.rowHeight我在调整.toDoListTable. 从 a 接收的字符串UITextfield在每行的末尾被切断。我在设置原型单元格时没有添加标签,因为我的字符串是从 UITextField. 我的代码如下:

override func viewDidLoad() {
    super.viewDidLoad()


        toDoListTable.estimatedRowHeight = 45.0

        toDoListTable.rowHeight = UITableViewAutomaticDimension


    }

}

然而,我的文字仍然被截断。有什么建议么?另外,我的代码在正确的位置吗?

我希望我的内容适应从UITextField.

编辑:通过添加解决问题cell.textLabel?.numberOfLines = 0

4

3 回答 3

3

使用它来设置行的高度:

override func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat
    {
         return 50 //your height
    }

文档:

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/index.html

于 2015-02-13T06:14:27.490 回答
3
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{
    return 30 // height you want to set.
}
于 2015-02-13T06:33:21.013 回答
1

我知道我迟到了,但我想正确回答我自己的问题。

我只是cell.textLabel?.numberOfLines = 0cellForRowAtIndexPath函数中添加了:允许多行不受限制的文本。

于 2015-03-17T02:13:47.933 回答