Ios 如何检索UITableViewCell的缩略图

Ios 如何检索UITableViewCell的缩略图,ios,objective-c,image,tableview,Ios,Objective C,Image,Tableview,我在UITableViewCell中显示多个图像,就像缩略图一样。但我正在努力检索所选UITableViewCell的图像。我必须这样做,以便在另一个ViewController中显示图像。我真的在努力解决这个问题 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = (UITab

我在UITableViewCell中显示多个图像,就像缩略图一样。但我正在努力检索所选UITableViewCell的图像。我必须这样做,以便在另一个ViewController中显示图像。我真的在努力解决这个问题

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MyCell"];
    if (cell==nil)
    {
         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellIdentifier"];

    }

   jsonDict = [jsonArr objectAtIndex:indexPath.row];
    //NSLog(@"imagess%@",jsonDict);
    cell.textLabel.text = [jsonDict objectForKey:@"ImageName"];

    stringg=[NSString stringWithFormat:@"%@",cell.textLabel.text];

    cell.textLabel.textAlignment=NSTextAlignmentCenter;


      NSData *imgData = [NSData dataWithBase64EncodedString:[jsonDict objectForKey:@"ImageData"]];

      imageView.image=[UIImage imageWithData:imgData];
     }
    return cell;

}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"%@",cell);

    NSString *textname=[NSString stringWithFormat:@"%@",cell.textLabel.text];
    NSLog(@"%@",textname);
 UIImage *image1 =selectedCell.imageView.image;
        age.ageimgae=image1;
}

您可以使用所选单元格的索引,而不是获取所选单元格的图像,以便在
JSonArray
中获取所需图像(就像您在
tableView cellforrowatinexpath:
中所做的那样):


didselectrowatinexpath
中,您需要识别特定的
Indexpath

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
{
jsonDict = [jsonArr objectAtIndex:indexPath.row];

 NSLog(@"the textr Name==%@",[jsonDict objectForKey:@"ImageName"]);

  UIImage *image1 = [UIImage imageWithData:[NSData dataWithBase64EncodedString:[jsonDict objectForKey:@"ImageData"]]];


NSData *imageData = UIImagePNGRepresentation(image1);
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"imageDataKey"];
[[NSUserDefaults standardUserDefaults]synchronize];
NSLog (@"Data Saved");


 }
在这里,您可以选择使用
nsserdefault
singleton
SharedInstance
将NSData或图像传递给另一个视图控制器

在secondviewcontroler.m中

  nsdata *imagedata=[[NSUserDefaults standardUserDefaults] objectForKey@"imageDataKey"];

  yourimgaename.image = [UIImage imageWithData:[NSData dataWithBase64EncodedString: imagedata]];

让你在cellforatindexpath中显示页面的屏幕截图和图像代码,然后选择RowatinDexpath立即检查@显示页面的屏幕截图
  nsdata *imagedata=[[NSUserDefaults standardUserDefaults] objectForKey@"imageDataKey"];

  yourimgaename.image = [UIImage imageWithData:[NSData dataWithBase64EncodedString: imagedata]];