IOS将自定义属性添加到uitableviewcell

时间:2012-02-07 19:59:10

标签: ios xcode uitableview custom-attributes

我正试图在xcode的IOS应用程序中实现这类功能。

HTML: <div data-foo="foobar"></div>

基本上,我有一个uitableviewcell,我想添加一个我可以获取和设置的自定义属性。

我知道我可以使用detailTextLabel.text并使文本透明,但我真正需要的是我可以设置和获取的幕后花絮,例如html中的data-foo,但是在xcode中/ ios带有uiTableViewCell

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

也许你可以创建一个名为MyTableCell的类,并在那里创建一些对象。在故事板中,将TableViewCell设置为MyTableViewCell。然后当你创建一个TableViewCell

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

MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:@"MyTableCell"];

//configure cell
//make any changes to the TableViewCell class with cell.myObject    

return cell;
}