我正在解决这个问题大约 2 周,只能传递字符串,而不是图像。
我以这种方法存储来自相机或库的图像。
-(IBAction)saveAction:(id)sender
{
Tricks *trick = [[Tricks alloc]init];
trick.trickName = self.trickLabel.text;
trick.trickPhoto = [[UIImageView alloc] initWithFrame:CGRectMake(0, 356, 320, 305)];
trick.trickPhoto.image = self.ImagePhoto.image;
[[Tricks trickList]addObject:trick];
}
在 tableViewClass 我将值存储到 detailView 的属性中
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"detailTrick"]){
NSIndexPath *indexPath = nil;
indexPath = [self.tableView indexPathForSelectedRow];
DetailViewController *detailViewController = [segue destinationViewController];
Tricks *trick = [[Tricks trickList] objectAtIndex:indexPath.row];
detailViewController.trickPhoto = [[UIImageView alloc]initWithFrame:CGRectMake(0, 358, 200, 200)];
detailViewController.fileText = trick.trickName;
detailViewController.trickPhoto = trick.trickPhoto;
//object = [Tricks trickList][indexPath.row]
}
}
每次都显示文字没有问题,但是detailViewController中没有图像。谢谢帮助。
detailViewController 的 viewDidLoad
[super viewDidLoad];
[self.detailButton setTitle:[NSString stringWithFormat:@"%@",_fileText] forState:UIControlStateNormal];
[self.trickPhoto setImage:_trickPhoto.image];