iOS8中自动调整tableViewCells大小仍会截断UILabel文本 [英] Auto-Resizing tableViewCells in iOS8 still truncate UILabel text

查看:52
本文介绍了iOS8中自动调整tableViewCells大小仍会截断UILabel文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用新方法在iOS8中调整UITableView单元格的大小,并且在一定程度上可行.我首先要确保标签贴在单元的容器视图的顶部,底部,尾端和前端,这是我在在线教程中被告知要做的,尽管我觉得这是问题所在.然后,在viewDidLoad中,输入以下几行:

I have been trying to use the new way to resize UITableView cells in iOS8 and to an extent, it works. I first make sure that the label is attached to the cell's container view at the top, bottom, trailing side and leading side which i was told to do on an online tutorial, though i feel that this is where the problem lies. In the viewDidLoad, I then put in the following lines:

self.tableView.estimatedRowHeight = 56
self.tableView.rowHeight = UITableViewAutomaticDimension

看完WWDC后,看来这几乎是我所需的有关单元格的全部内容,因此我进入了界面构建器,并将标签的"lines"属性设置为0,再次按照视频.正如我所期望的那样,它会调整所有单元格的大小,尽管它总是使它们的一行太小,以致于全文无法容纳.下面是其外观的屏幕截图.请询问您是否需要更多信息或照片,是否可以使您更轻松地给我一些建议.我意识到这可能是我自己的一个愚蠢错误,但由于iOS 8太新了,因此没有什么地方值得一看.非常感谢

After watching the WWDC, it appears that this is pretty much all I need in regards to the cell, so then i went into the interface builder and set the "lines" property for the label to 0, again as instructed in the video. It resizes all of the cells as I would expect though it always makes them one line too small so that the full text doesn't fit in. Below is a screenshot of what it looks like. Please ask if you need more information or photos if it makes it easier for you to give me some advice. I realise this is probably a stupid error on my part but there are few places to look as iOS 8 is so new. Thanks a lot

推荐答案

我遇到了同样的问题.我必须完成所有3条建议才能使其正常工作:

I had the same problem. I had to do all 3 suggestions to get it working:

将标签上的行数设置为0.

Set the number of lines on the labels to 0.

cellForRowAtIndexPath中:在分配所需的字符串之前,将单元格标签的文本设置为空字符串.

In cellForRowAtIndexPath: set the cell labels' text to an empty string before assigning the desired string.

viewDidAppear:中调用 [tableView reloadData] .

我确实尝试过单独进行操作,但这没有用.

I did try doing them individually and it doesn't work.

在那之后我遇到了一个小问题...在重新加载表格之前,可以看到文本的原始布局,并且在调整文本时会导致看起来很奇怪的文本闪烁".因此,我创建了一个布尔并将单元格标签设置为隐藏.当 viewWillAppear:被调用时,我将该布尔值设置为true,并在 cellForRowAtIndexPath:中将布尔值设置为true时取消隐藏标签.

I had a minor issue after that however...The original layout of the text is in view before the table reloads and causes a weird looking text "flicker" when the text gets adjusted. So I created a bool and set the cell labels to hidden. When viewWillAppear: gets called i set that bool to true and in cellForRowAtIndexPath: I unhide the labels if the bool is true.

无论如何希望他们能解决此问题,因为它是一个了不起的功能.

In any case hopefully they get this fixed because it's an awesome feature.

这篇关于iOS8中自动调整tableViewCells大小仍会截断UILabel文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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