想要通过 accessorybuttontapped 传递数据
Want to Pass data with accessorybuttontapped
我有以下代码:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.textLabel.text];
它工作得很好。但我想用 RecordTableViewCell 替换 UITableViewCell,这样我就可以使用 recordLabel 而不是 textLabel。
代码应该是
RecordTableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.recordLabel.text];
但是不行。它说 "incompatible pointer types initializing RecordTableViewCell with an expression of type UITableViewCell"...
请帮忙。谢谢。
只需像这样向您的代码中添加强制转换:
RecordTableViewCell *recordCell = (RecordTableViewCell *) [tableView cellForRowAtIndexPath:indexPath];
我有以下代码:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.textLabel.text];
它工作得很好。但我想用 RecordTableViewCell 替换 UITableViewCell,这样我就可以使用 recordLabel 而不是 textLabel。 代码应该是
RecordTableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.recordLabel.text];
但是不行。它说 "incompatible pointer types initializing RecordTableViewCell with an expression of type UITableViewCell"... 请帮忙。谢谢。
只需像这样向您的代码中添加强制转换:
RecordTableViewCell *recordCell = (RecordTableViewCell *) [tableView cellForRowAtIndexPath:indexPath];