iPhone/iPad SimpleTableViewCells:什么取代了表格单元格中不推荐使用的setImage setText?

Mik*_*keN 6 iphone objective-c uitableview ipad

iPhone/iPad SimpleTableViewCells:什么取代了表格单元格中不推荐使用的setImage setText?

下面的代码给出了不推荐使用setImage和setText的警告.是什么取代了他们?获得这种简单行为的新方法是什么?

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

if (cell == nil) {
  cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
       reuseIdentifier: SimpleTableIdentifier] autorelease];
}
cell.image=[UIImage imageNamed:@"Wazoo.png"];;
cell.text = @"Wazoo";

那么,在没有做大量工作或获得警告的情况下,与单元格的图像/文本具有相同效果的最简单方法是什么?

mat*_*odv 11

随着iOS SDK的新版本,不推荐使用setText和setImage属性,它们被setText的textLabel.text替换为setImage的imageView.image ...
使用这个新属性,您的代码将是:

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

if (cell == nil) {
  cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
       reuseIdentifier: SimpleTableIdentifier] autorelease];
}
cell.imageView.image = [UIImage imageNamed:@"Wazoo.png"];;
cell.textLabel.text = @"Wazoo";
Run Code Online (Sandbox Code Playgroud)

当单元格使用preimpostated样式(如UITableViewCellStyleDefault,UITableViewCellStyleSubtitle,UITableViewCellStyleValue1和UITableViewCellStyleValue2或CGRect)时,通常会使用此属性...
如果还要显示副标题,则要使用的代码为:

cell.detailTextLabel.text = @"Your Subtitle Here!";
Run Code Online (Sandbox Code Playgroud)