2011-08-08 8 views
0

Xcodeでテーブルの行のセル内のテキストを設定することはエラーiPhone:エラー私はこのコードを使用する場合、4.2

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] ; 
} 

// Set up the cell 
SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate]; 
Animal *animal = (Animal *)[appDelegate.animals objectAtIndex:indexPath.row]; 

[cell setText:animal.name]; 
return cell; 

}

iが使用[セルのsetText:animal.name]を示しながら、それを'setText'のようにエラーが表示されます。

答えて

2

使用[cell.textLabel setText:animal.name];

1

Yeah..use UITableViewCelltextプロパティのiOS 3.0で廃止されたためだ代わりに次の行..

[cell.textLabel setText:(NSString *)] 
1

- 参照hereを参照してください。テキストラベルに使用されているUILabelは、UITableViewインスタンスのtextLabelプロパティとして公開されています。代わりにこれを試してください:

cell.textLabel.text = animal.name;

関連する問題