This is a beginner's question that I fear:
I have a UIText that spans the entire screen. I have another transparent view on top of this UITextView to be able to recognize gesture movements (horizontally and vertically), for example:
- (void)viewDidLoad { [super viewDidLoad]; // UITextView CGRect aFrame = CGRectMake(0, 0, 320, 480); aTextView = [[UITextView alloc] initWithFrame:aFrame]; aTextView.text = @"Some sample text."; [self.view addSubview:aTextView]; // canTouchMe CGRect canTouchMeFrame = CGRectMake(0, 0, 320, 480); canTouchMe = [[UIView alloc] initWithFrame:canTouchMeFrame]; [self.view addSubview:canTouchMe]; }
Let's look at how the user touches (does not check) the canTouchMe view. In this case, I would like the canTouchMe view to disappear and pass a touch to the UITextView hiding beneath it to enter edit mode and enable the βnaturalβ scroll options that the UITextView has (that is, only horizontally).
The my touchhes method began to look like this:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; UITouch *touch =[touches anyObject]; gestureStartPoint = [touch locationInView:self.view]; }
How to tell this method that if it only recognizes ONE touch , it should hide canTouchMeFrame and PASS ON touch in a UITextView?
Sorry if this is basic, but I have no idea how to implement this. Thanks for any suggestions.
EDIT:
I introduced the touchEnded method, but I still had no luck. Touch will not be redirected to UITextView. I need to double click to edit it:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ [super touchesMoved:touches withEvent:event]; UITouch *touch = [touches anyObject]; CGPoint currentPosition = [touch locationInView:self.view]; CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
}