Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableViewcell图像将显示在UIImageView的下一个视图中_Iphone_Ios_Xcode - Fatal编程技术网

Iphone UITableViewcell图像将显示在UIImageView的下一个视图中

Iphone UITableViewcell图像将显示在UIImageView的下一个视图中,iphone,ios,xcode,Iphone,Ios,Xcode,我可以用相机拍照并保存在文档文件夹中。图像将加载到UITableView。 如果我选择特定行,对应图像将转到下一个视图并显示图像。 这是我的密码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Enter into cellforRow"); static NSString *CellIdentif

我可以用相机拍照并保存在文档文件夹中。图像将加载到
UITableView
。 如果我选择特定行,对应图像将转到下一个视图并显示图像。 这是我的密码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSLog(@"Enter into cellforRow");

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    NSString *FileName = [NSString stringWithFormat:@"test1.png"];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *tempPath = [documentsDirectory stringByAppendingPathComponent:FileName];

    //image
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10.0, 10.0, 60.0, 60.0)];

    [imageView setImage:[arrayOfImages objectAtIndex:indexPath.row]];
    [cell.contentView addSubview:imageView];

    return cell;
}

现在在
didSelectRowAtIndexPath
方法中添加什么

didSelectRowAtIndexPath

UIImage *image = [arrayOfImages objectAtIndex:indexPath.row]; 
    ImageViewController *viewer = [[ImageViewController alloc] initWithNibName:@"ImageViewController" bundle:nil];
    viewer.selectedImage = image;
    [self.navigationController pushViewController:viewer animated:YES];
ImageViewController.h


@property(非原子,保留)UIImage*selectedImage

在子视图控制器中显示图像有两种方法

  • 在subViewController中定义属性,并在导航到subViewController之前在parentViewController中指定值
  • 在导航到子ViewController之前,请传递图像路径。在子视图控制器中,根据imagePath显示图像