我有這個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