Question

I used a UICollectioView to load Images with a NBMutableArray from web and working well.

Now adding a Tap Gesture Recognizer on my UIImageView and i will pass the information to other view like a segue identifier example:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if([@"getImage" isEqualToString:segue.identifier]) {
        NSIndexPath *index = [self.collectionView indexPathForCell:sender];
        [[segue destinationViewController] setLinkImg:(arrayCollectionImages)[index.row][@"image"]];
    }

In MyStoryBoard i used this:

enter image description here

if I leave only this function my app go to crash when tap on image.

any body know how can do that?

Was it helpful?

Solution

No need to add Tap Gesture Recognizer to UIImageView. Just connect 'Triggered Segues' of CollectionCell to your destination ViewController. So that sender will be CollectionCell in *- (void)prepareForSegue:(UIStoryboardSegue )segue sender:(id)sender method.

enter image description here

OTHER TIPS

:)

obviously it will crash.

it will search the method "setLinkImg" on details page where you need to show this.

so make sure this method is active on details page where you are going to show image.

and again check also the collection array should contains any value

so in details page where you need to show image should contain

Code should be there in details page

- (void) setLinkImg:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;

        // Update the view.
        [self configureView];
    }       
}

- (void)configureView
{
    // Update the user interface for the detail item.

    if (self.detailItem) {
        your-imageview-object.image = [uiimage imagename:self.detailItem)];

      or any url should set on image view object.
    }
}

let me inform if any need

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