Question

I'm currently using a plist to populate my table view rows(i.e. Name, Description and Image). When the user selects a row, a new controller is pushed up with an imageView presenting the rows image in full screen.

The problem that I'm facing is, passing the string to the new viewController's imageView.

All the NSLog's return the correct information, except that when it logs the UIImageView, it returns null then. Am I not connecting it correctly? The row doesn't display any image until it's selected (essentially the row is acting, similar to a thumbnail).

Any help would be greatly appreciated thank you!!!

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

    NSDictionary *childDictionary = [mainChildren objectAtIndex:indexPath.row];

    //Image Name NSString from plist
    childImage = [childDictionary objectForKey:@"Child Image"];

    if ([childDictionary objectForKey:@"Child Image"] == nil) {

        NSLog(@"No Image String Found.");
    }

    else {

        NSLog(@"Image String Found. Image Name is: %@", childImage);

        UIImage *myImage = [UIImage imageNamed:childImage];
        NSLog(@"Image Found. Image is: %@", myImage);

        UIImageView *childImageView = [childImageView setImage:myImage];        
        NSLog(@"ImageView Found. ImageView is: %@", childImageView);

        FullscreenImageViewController *imgViewer = [[FullscreenImageViewController alloc] init];
        imgViewer.fullScreenImageView = childImageView;
        [self presentViewController:imgViewer animated:YES completion:nil];
    }
}
Was it helpful?

Solution

When you instantiate a new UIImageView, it should be [[UIImageView alloc] initWithImage:image].

Or since your full screen image controller has property of image view, e.g. fullScreenImageView, you can just set the image of the property directly with a UIImage instance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top