Quote:
Originally Posted by anuragphadke
Scott,
I am trying to implement what you said.. Here's my code
I added a hittest method in my ScrollView
Code:
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
scrollView.delaysContentTouches = YES;
return self;
The above code allows me to detect all my touches in UIScrollview. For eg:
Code:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touch moved");
}
However, I can no longer perform any swipe, scroll or any other gesture in my WebView class implemented inside UIScrollView.
without
everything works but I cannot recognize any gestures.
Any tips?
|
This is what I use in my subclass of UIScrollView
// Code begin here
@implementation MyScrollView
@synthesize imageId;
-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
NSLog(@"Inside Touches Began");
if (!self.dragging) {
//********** not Dragging ***************
[self.nextResponder touchesEnded: touches withEvent:event];
for (UITouch *touch in touches) {
for (int i = 1; i < [self subviews].count; i++)
{
//Looping thru all images to see which one was touched
if(CGRectContainsPoint([[self viewWithTag:i]frame], [touch locationInView:self])){
NSLog(@"touched %d th view",i);
//get current image if not dragging
self.imageId = i;
}
}
}
}
else{
for (UITouch *touch in touches) {
for (int i = 1; i < [self subviews].count; i++)
{
//*************** Dragging **********************
if(CGRectContainsPoint([[self viewWithTag:i]frame], [touch locationInView:self])){
NSLog(@"touched %d th view",i+1);
//get next image if dragging
self.imageId = i+1;
}
}
}
}
[super touchesEnded: touches withEvent: event];
}
Hope this helps