I need to pass an image from one view to another view.In the firstView I m getting a base64 data from service URL and I have converted it to particular image and displaying in tableviewcell.Now when I tap a particular cell the corresponding image should be passed from firstView to secondView.But couldn’t get it.getting error “Program received signal SIGABRT”
This is the code I m working on:
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];
}
How can I get it ?
This line is wrong:
viewWithTag:will return a view, in this case aUIImageView, which you are treating like aUIImage.You need to get the
UIImagefrom theUIImageView. You can do that like this:or in one line like this: