У меня есть этот TableViewController, который имеет ячейки, которые имеют одну метку и imageView, которые мне нужно передать на следующий viewController.Передача значений в следующий viewController не работает
как на классе, которая представляет tableViewCells на первом ВК и на втором VC эти элементы объявлены как
@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