2010-10-20 42 views
7

我正在创建示例hello world应用程序。代码如下。我如何删除在c [cell setText:@“Hello World”]处的警告:UITableViewCell设置文本

;在下面的代码中,因为它已被弃用。

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

[cell setText:@"Hello World"]; 

回答

21

集小区标签文本

cell.textLabel.text = @"Hello World"; 

和细节标签文本

cell.detailTextLabel.text = @"yourText"; 
+0

感谢这个答复。 – boom 2010-10-20 05:24:24

3

还有更多的Objective-C这样做的方式:

[[cell textLabel] setText:@"Hello World"]; 

和细节标签文字:

[[cell detailTextLabel] setText:@"Hello World"]; 
+5

这实际上是较少的Objective-C方法。点符号后来被引入并出于某种原因。 – 2014-12-17 16:48:40

1

在雨燕3.0的应该是

cell.textLabel?.text = "Hello World"