我正在創建示例hello world應用程序。代碼如下。我如何刪除在c [cell setText:@「Hello World」]處的警告:UITableViewCell設置文本
;在下面的代碼中,因爲它已被棄用。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell setText:@"Hello World"];
我正在創建示例hello world應用程序。代碼如下。我如何刪除在c [cell setText:@「Hello World」]處的警告:UITableViewCell設置文本
;在下面的代碼中,因爲它已被棄用。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell setText:@"Hello World"];
集小區標籤文本
cell.textLabel.text = @"Hello World";
和細節標籤文本
cell.detailTextLabel.text = @"yourText";
還有更多的Objective-C這樣做的方式:
[[cell textLabel] setText:@"Hello World"];
和細節標籤文字:
[[cell detailTextLabel] setText:@"Hello World"];
這實際上是較少的Objective-C方法。點符號後來被引入並出於某種原因。 – 2014-12-17 16:48:40
在雨燕3.0的應該是
cell.textLabel?.text = "Hello World"
感謝這個答覆。 – boom 2010-10-20 05:24:24