我需要将图像从一个视图传递到另一个视图。在第一个视图中,我从服务 URL 获取 base64 数据,并将其转换为特定图像并显示在 tableviewcell 中。现在,当我点击特定单元格时,相应的图像应该是从 firstView 传递到 secondView。但无法获取它。出现错误“程序收到信号 SIGABRT”
这是我正在处理的代码:
FirstView.m
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSData *data = [NSData dataFromBase64String:yBase64String];
UIImage* image = [UIImage imageWithData: data];
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,10,90,150)];
myImageView.tag = 120;
myImageView.image = image;
[cell addSubview:myImageView];
[myImageView release];
return cell;
}
- (void) tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
SecondView *scnd = [[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
UIImage *image=(UIImage *)[cell viewWithTag:120];
scnd.provImage=pImage;
[self presentModalViewController: scnd animated:NO];
}
SecondView.m
-(void)viewDidLoad
{
[super viewDidLoad];
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(2,25,90,80)]; //getting error at this line
myImageView.image= self.provImage;
[self.view addSubview: myImageView];
[ myImageView release];
}
我怎么才能得到它 ?