简体   繁体   English

Parse.com图像库打开图像细节视图

[英]Parse.com image gallery open image detail view

I haven't been programming for very long and I am trying to create a simple image gallery using Parse.com, I have followed this tutorial https://www.parse.com/tutorials/saving-images but using storyboards instead of nibs. 我已经很长时间没有编程了,所以我试图使用Parse.com创建一个简单的图像库,我按照本教程https://www.parse.com/tutorials/saving-images进行操作,但是使用情节提要而不是笔尖。

I managed to got most of it working but I'm stuck at the last hurdle, when it comes to opening the selected image full size in a new view. 我设法使其大部分工作正常,但在新视图中以全尺寸打开所选图像时,我遇到了最后一个障碍。 Following other answers given around the web I have tried to pass the image to the detail view in - (void)prepareForSegue: but I'm still having no luck. 在网上给出了其他答案之后,我尝试将图像传递到- (void)prepareForSegue:的详细信息视图- (void)prepareForSegue:但是我仍然没有运气。

My code in ViewController.h currently looks like this 我在ViewController.h中的代码当前看起来像这样

- (void)buttonTouched:(id)sender {
    PFObject *theObject = (PFObject *)[allImages objectAtIndex:[sender tag]];
    PFFile *theImage = [theObject objectForKey:@"imageFile"];

    NSData *imageData;
    imageData = [theImage getData];
    selectedPhoto = [UIImage imageWithData:imageData];
    [self performSegueWithIdentifier:@"goGo" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if([[segue identifier] isEqualToString:@"goGo"]) {
        PhotoDetailViewController *pdvc = [[PhotoDetailViewController alloc] init];
        pdvc.selectedImage = selectedPhoto;
    }
}

and in DetailViewController.h 并在DetailViewController.h中

- (void)setDetailImage {
    self.photoImageView.image = selectedImage;
}

When it comes to loading the image the view opens blank, any help on this would be a massive help. 在加载图像时,视图将打开空白,对此的任何帮助将是巨大的帮助。 If it makes it easier I can upload the project. 如果它更容易,我可以上传项目。

Thanks in advance, Chris 预先感谢克里斯

Your actual prepareForSegue statements does nothing : you're initializing selectedImage to a totally new PhotoDetailViewController but not the one which will be presenting. 您实际的prepareForSegue语句不执行任何操作:您正在将selectedImage初始化为一个全新的PhotoDetailViewController而不是将要显示的那个。

Try to replace 尝试更换

PhotoDetailViewController *pdvc = [[PhotoDetailViewController alloc] init];

by 通过

PhotoDetailViewController *pdvc = (PhotoDetailViewController *)segue.destinationController;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM