我很沮喪(並且很可能對某些令人難以置信的顯而易見的事物是盲目的)。我有一個UITableView,我想用它做非常正常的事情,比如每行顯示文本。爲此,我實施了通常的代理方法tableView:cellForRowAtIndexPath:
。這被稱爲預期。根據文檔,我應該創建一個UILabel對象,並將其設置爲新的UITableCell上的textLabel
屬性。但是我碰到了無法識別的選擇器setTextLabel:
- 編譯器正確地警告我它不在那裏。已棄用的方法setText:
存在且工作正常(有警告)。我肯定似乎對建設3.0庫(我沒有得到在其他目標的下拉列表中選擇。所以我很困惑。我缺少什麼?爲什麼我的UITableViewCell沒有textLabel屬性?
感謝。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
UILabel * label = [[[UILabel alloc] init] autorelease];
[label setText:@"Foo."];
[cell setTextLabel:label]; // BOOM.
return cell;
}
D'oh。謝謝... – 2010-01-26 03:35:33