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显示图像李>