1

I have several images loading in a scrollview.
I set up the C4ScrollView like this:

viewer = [C4ScrollView scrollView:CGRectMake(20, 30, 75, self.canvas.height - 50)];
viewer.contentSize = CGSizeMake(75, 1000);
[self.canvas addSubview:viewer];

and then I put the images in and add the tap gesture (in a for loop) like this:

C4Image* img = [C4Image imgWithUrl:imgUrl];    
[viewer addImage:img];
img.userInteractionEnabled = YES;
[img addGesture:TAP name:@"tap" action:@"tapped"];
[viewer listenFor:@"tapped" fromObject:img andRunMethod:@"imgTap:"];

then I have a method called imgTap like this:

-(void)imgTap:(NSNotification *)notification {
    C4Image *img = (C4Image *)notification.object;
    C4Log(@"image tapped");
}

But imgTap: method never gets called... Am I doing something wrong? Or do I have to do something differently in order to get the C4Image to recognize the gesture?

Greg Debicki
  • 235
  • 2
  • 6
  • 1
    do you specifically need the tap gesture? if not, using `touchesBegan` might fulfill what you need. – C4 - Travis Oct 28 '13 at 06:10
  • TouchesBegan fulfilled me in the end. How would one go about using the tap gesture though? Is it possible? (just worried about touchesBegan intercepting a pan on the scrollview) – Greg Debicki Oct 28 '13 at 17:07
  • This is actually a bug. I filed it here: https://github.com/C4Framework/C4iOS/issues/112 . The C4Object class doesn't properly respond to `listenFor` from messages like `swipedUp`, `tapped` etc... – C4 - Travis Oct 28 '13 at 18:35

0 Answers0