【发布时间】:2014-03-05 10:16:01
【问题描述】:
有没有办法在代码中向 UITableViewCell 添加一些隐藏信息?
用例:
- 在活动提要中,
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath被调用,每个单元格都有一个活动。每个都有自己独特的“activityId”。 - 每个单元格中都有一些按钮(带有独特的标签),按下时,给定的活动会被“点赞”
- 每个按钮都有一个 IBOutlet,然后它会调用模型来处理类似的事情
IBOutlet 的代码是:
- (IBAction)buttonUp:(UIButton *)sender {
UIButton *btn = (UIButton *) sender;
UITableViewCell *cell = (UITableViewCell *) [[btn superview] superview];
UIView *cellView = [cell.contentView viewWithTag: ..myUniqueButtonTag.. ];
NSLog(@"activityId is: %@", ...);
}
【问题讨论】:
-
使用 cell.accessibilityValue 并为其分配数据.. 当点击找到该单元格及其accessibilityValue
标签: ios objective-c cocoa-touch uitableview