我有这个tableViewController有单元格,我有一个标签和一个imageView,我需要传递给下一个viewController。将值传递给下一个viewController不工作
在两个代表在第一VC和第二VC的tableViewCells这些元素的声明等
@property (weak, nonatomic) IBOutlet UIImageView *thumbnail;
@property (weak, nonatomic) IBOutlet UILabel *fileName;
一旦一个电池的公开内容按钮被点击的类,它触发prepareForSegue:sender:
,我有这样
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// the user tapped on the disclosure button of a tableView cell... get the cell
FileManagerTableViewCell *cell = (FileManagerTableViewCell *)sender;
// this is the next viewController that will show the cell in detail
FileManagerDetailVC *detail = [segue destinationViewController];
detail.thumbnail.image = cell.thumbnail.image;
detail.fileName.text = cell.fileName.text;
// at this point, `cell.thumbnail.image` and `cell.filename.text` **are not nil**
// if I check `detail.thumbnail.image` and `detail.filename.text` when the detail
// is presented, they are nil
}
我试图创建新的对象,希望这个问题是单元对象被释放,所以我这样做:
detail.thumbnail.image = [UIImage imageWithCGImage:[cell.thumbnail.image CGImage]];
detail.fileName.text = [NSString stringWithString:cell.fileName.text];
或者干脆
detail.thumbnail.image = [cell.thumbnail.image copy];
detail.fileName.text = [cell.fileName.text copy];
没有变化。
我在想什么?
你的意思是这样做? 'detail.thumbnail.image = [UIImage imageWithCGImage:[cell.thumbnail.image CGImage]];'?不工作。对象是零。我已经为我的问题添加了更多信息。 – SpaceDog 2014-09-25 18:42:09