2010-10-20 35 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"