UITableViewCell的字幕不会更新 [英] Subtitles of UITableViewCell won't update

查看:62
本文介绍了UITableViewCell的字幕不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我开始为iOS8准备好我的应用程序。
我发现我的UITableCells的字幕不会在 viewWillAppear 中更新。
我把它带到了一个最小的例子:

Today I started to get my apps ready for iOS8. I discovered that the subtitles of my UITableCells won't update within viewWillAppear. I brought that down to a minimal example:

我有一个带有2个单元格的静态单元格TableViewController(style = subtitle)
一个副标题是空的,另一个设置。

I've got a static cell TableViewController with 2 cells (style = subtitle) One subtitle is empty the other one is set.

我更新这样的字幕:

- (void) viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];
  [[self.without detailTextLabel] setText:@"foobar"];
  [[self.with detailTextLabel] setText:@"barfoo"];
}

虽然Everythin在iOS7(以及6和5)下工作,但iOS8不会更新第一个单元格的标题。

While everythin works under iOS7 (and 6 and 5), iOS8 won't update the title of the first cell.

然而,当我触摸单元格时,它会更新并显示文本。

However, when I touch the cell it will update and show the text.

这是一个模拟器问题?一个bug?我做错了什么?

Is this a simulator issue? A bug? Am I doing something wrong?

推荐答案

作为一个临时的工作我简单介绍了文本标签中的空白并以编程方式在哪里我将标签文本设置为nil,我将其设置为空格

As a temporary work around I simple introduced a blank space in the text label and programmatically where I set the label text to nil, I set it to a blank space

cell.detailTextLabel.text = @" ";

相应地调整你的逻辑以处理一个单独的空格为零。

Adjust your logic accordingly to deal with a lone blank space as nil.

对我来说,即使在加载了viewcontroller之前我已经准备好了一个字符串,详细文本标签也没有显示出来。每当视图控制器出现时,我的许多单元格中的一个都会将详细文本标签中的当前日期显示为默认值,但这也不起作用。

For me the detail text label didn't show up even though I had a string ready for it before the viewcontroller loaded. one of my many cells shows the current date in a detail text label as default whenever the view controller appears, but that didn't work either.

我认为这有一些东西如果最初设置为nil,iOS 8无法更新文本标签的文本这一事实。

I think this has something to do with the fact that the iOS 8 is not able to update the text label's text if it set to nil initially.

所以请注意你介绍在原型单元格中也是一个空白区域,在界面构建器中。令人惊讶的是,我的自定义单元格标签中的文本工作正常。

So see to it that you introduce a blank space in your prototype cell as well, in interface builder. Surprisingly text in labels of my custom cells are working fine.

这篇关于UITableViewCell的字幕不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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