我可以通过相机拍照并保存在文件夹中。图片将加载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
方法
答案 0 :(得分:0)
在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 (nonatomic , retain) UIImage *selectedImage;
答案 1 :(得分:0)
有两种方法可以在子视图控制器中显示图像。