xcode 不推荐使用的 UITableViewCell setText 的替代方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1089676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:05:24  来源:igfitidea点击:

alternative to deprecated UITableViewCell setText?

iphonexcodeuitableviewwarningsdeprecated

提问by Daryl Spitzer

Code in the book Beginning iPhone Development(by Dave Mark & Jeff LaMarche) assigns to the UITableViewCell text property:

Beginning iPhone Development》(Dave Mark & Jeff LaMarche 着)一书中的代码分配给 UITableViewCell 文本属性:

UITableViewCell *cell = ...
...
cell.text = ...

This assignment brings up a "'setText' is deprecated..." warning. What should I use as an alternative?

此分配会显示“不推荐使用‘setText’...”警告。我应该使用什么作为替代?

Also, how do I open the long URL in the warning (in Xcode) without retyping the whole thing?

另外,如何在不重新输入整个内容的情况下(在 Xcode 中)打开警告中的长 URL?

回答by marcc

try:

尝试:

cell.textLabel.text = @"test";

(Ah, it's nice to be answer 3.0 SDK questions now)

(啊,很高兴现在回答 3.0 SDK 问题)

回答by Mark

To address the second question.

针对第二个问题。

I'm not sure what you mean by URL but to get the full text of the build output, which is where the warning bubble comes from:

我不确定你说的 URL 是什么意思,但要获取构建输出的全文,这是警告气泡的来源:

1) open the build window (default key binding Command-Shift-B)

1)打开构建窗口(默认键绑定Command-Shift-B)

At the bottom of the build progress view there are four buttons. The buttons from left to right are a checkmark, a warning symbol, some dotted lines, and a popup menu for more options.

在构建进度视图的底部有四个按钮。从左到右的按钮是复选标记、警告符号、一些虚线和更多选项的弹出菜单。

Make sure the third symbol, the one with the dotted lines, has a dark grey background. Toggle it if you are in doubt. The new view that is exposed when this button is pressed has the full text output from the build process (compiler, linker, shell script output, etc...)

确保第三个符号(带有虚线的符号)具有深灰色背景。如果您有疑问,请切换它。按下此按钮时显示的新视图具有构建过程的全文输出(编译器、链接器、shell 脚本输出等...)

I believe this is what you are asking about.

我相信这就是你要问的。

You can use the Command-= and Command-Shift-+ to move through the warnings and errors. When you do this the full text of each warning/error bubble will be selected in the full output view.!

您可以使用 Command-= 和 Command-Shift-+ 来浏览警告和错误。执行此操作时,将在完整输出视图中选择每个警告/错误气泡的全文。!

回答by taus-iDeveloper

Deprecated suggests that you change your code to use the new method suggested by Apple. Any deprecated methods would be removed in the future update releases (for ex: they might remove it from OS 3.1) So, instead of setText, use this

Deprecated 建议您更改代码以使用 Apple 建议的新方法。任何不推荐使用的方法都将在未来的更新版本中删除(例如:他们可能会从 OS 3.1 中删除它)所以,不要使用 setText,而是使用这个

 [cell.textLabel setText] method

回答by Yash Kaushik

you Use This Code:-

您使用此代码:-

"cell.textLabel.text"

“cell.textLabel.text”

Remove The Warning Of Text deprecated UITableViewCell setText?

删除文本已弃用 UITableViewCell setText 的警告?