Restrict user to one finger touch on UIView to avoid frame issues - iphone

I know there are lots of questions on multi finger touches and restrictions here and there,but none of them seem to work.All they suggest is to try setting exclusive touch and disable multi touch i.e.:
[self.view.subviews makeObjectsPerformSelector:#selector(setExclusiveTouch:) withObject:[NSNumber numberWithBool:YES]];
[self.view setMultipleTouchEnabled:NO];
Note: Initially when I used self.view.exclusiveTouch = NO; ,it didn't work for me.Mr.Hlung's comment in the 1st link provided some useful info of enabling the subviews exclusive touch through selector.
But they seem to work incomplete.I have a game view where there are multiple images on left and their corresponding images on the right.User has to drag the left image to the respective right image and match it.I am using UIPanGestureRecognizer to do so.Here comes a scenario which was the outcome of some rash testing by a tester in my office :)
When the user scrambles the images,i.e. plays awkwardly with all/few of his fingers,what happens is the frames are getting disturbed or few images overlap with one another.This is all because some where multiple touch is still available for user.Hence I want to eliminate that feature.I am also aware of the fact that there is a method called -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event ,through which we can detect the number of user touches.What if I delete all user touches if the count is more than 1,i.e. if more than 1 finger touch is detected!!!
But I found no method to remove touches there,I also tried to assign last touch object to my image view through which I thought would ignore the rest of touches detected,i.e.:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([event allTouches].count>1)
{
UITouch *touch = [[touches allObjects] lastObject];
self.dragObjectImageView = (UIImageView *)[touch view];
}
}
Even this doesn't seem to work.
EDIT-Setting Max and Min number of touches:
I have also set the pan gesture's max and min no of touches to 1 as well,i.e.:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view.subviews makeObjectsPerformSelector:#selector(setExclusiveTouch:) withObject:[NSNumber numberWithBool:YES]];
for(UIImageView *iView in self.movableArray){
if ([iView isMemberOfClass:[UIImageView class]]){
UIPanGestureRecognizer * recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:#selector(handlePan:)];
recognizer.minimumNumberOfTouches = 1;
recognizer.maximumNumberOfTouches = 1;
iView.multipleTouchEnabled = NO;
[iView addGestureRecognizer:recognizer];
[iView setUserInteractionEnabled:YES];
recognizer.delegate = self;
}
}
}
Tried another tactic of disabling user interaction for image if multiple touches are detected,but in vain!
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([event allTouches].count > 1)
{
for (UIView* view in self.view.subviews)
{
if ([view isKindOfClass:[UIImageView class]])
{
[view setUserInteractionEnabled:NO];
}
}
}
else
{
for (UIView* view in self.view.subviews)
{
if ([view isKindOfClass:[UIImageView class]])
{
[view setUserInteractionEnabled:YES];
}
}
}
}
Some people might say there can't be a case where user will use multiple fingers to play.But I was asked to fix the issue and a developer has to obey and respect the testers perspective as well.
Can some one please help me get rid of the problem.
Thanks every one in advance :)

Instead of setting exclusive touch to our own view,turning on the same for the subview or the view we assign to self.view worked,in my case it is...
[gameView.subviews makeObjectsPerformSelector:#selector(setExclusiveTouch:) withObject:[NSNumber numberWithBool:YES]];
Hope it helps some one,thanks :)

As per apple documentation for the property multipleTouchEnabled in UIView Class Reference
multipleTouchEnabled
Other views in the same window can still receive touch events when
this property is NO. If you want this view to handle multi-touch
events exclusively, set the values of both this property and the
exclusiveTouch property to YES.
I see in your code, you've set setExclusiveTouch to all subviews but setMultipleTouchEnabled only for the container view and not all image views. Add the following line before/after setting exclusive touch and single touch may work correctly.
[self.view.subviews makeObjectsPerformSelector:#selector(setMultipleTouchEnabled:) withObject:[NSNumber numberWithBool:NO]];

Related

Disable touch events on certain areas of iPhone screen

I want to disable touches on all areas of the screen apart from a specific few points (e.g buttons). I.e. I don't want 'touchesBegan' to trigger at all when I tap anything other than a button. Calling
self.view.userInteractionEnabled = NO;
has the desired effect for not registering touches, but then of course I can't tap any buttons. I basically want the button to still work, even if there are 5 points touching the screen, i.e. all touch inputs have been used up, and the button represents the 6th.
Is this possible?
I've tried inserting a view with userInteraction disabled below my buttons, but it still registers touches when the user taps the screen. It seems the only way to disable touch registering is to do so on the entire screen (on the parent UIView).
UPDATE:
I've tried using gesture recognizers to handle all touch events, and ignore those that don't qualify. Here is my code:
#interface ViewController : UIViewController <UIGestureRecognizerDelegate>
...
- (void)viewDidLoad
{
[super viewDidLoad];
UIGestureRecognizer *allRecognizer = [[UIGestureRecognizer alloc] initWithTarget:self action:nil];
allRecognizer.delegate = self;
[self.view addGestureRecognizer:allRecognizer];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
CGPoint coords = [touch locationInView:self.view];
NSLog(#"Coords: %g, %g", coords.x, coords.y);
if (coords.y < 200) {
[self ignoreTouch:touch forEvent:nil];
return TRUE;
}
return FALSE;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(#"%i touch(es)", [touches count]);
}
However the screen still 'reads' the touches, so if I place 5 fingers down, the 6th one won't trigger a button press...
You need to set up an invisible UIButton and lay it between the view that should not register touches and the UIButtons that should still be active.
Now you need to set the invisible button's 'userInteractionEnabled':
//userInteractionEnabled == NO => self.view registeres touches
//userInteractionEnabled == YES => self.view doesn't register touches
[_invisibleButton setUserInteractionEnabled:NO];
What really matters in this solution is that both - the invisible and the visible buttons are direct subviews of the VC's view.
You can download an example project from my dropbox:
https://dl.dropboxusercontent.com/u/99449487/DontTapThat.zip
However this example just prevents the handling of certain touches. Completly ignoring input isn't technically possible: Third party apps are not responsible for for detecting input. They are just responsible for handling input. The detection of touch input is done iOS.
The only way to build up a case like you describe it in the comments is to hope that iOS won't interpret the input of your case as a "finger" because it's most likely going to cover an area that's way bigger than a finger.
So in conclusion the best way would be to change the material of the case you're about to build or at least give it a non conductive coating. From a third party developers point of view there is no way to achieve your goals with software if there is a need for 5 fingers as described in the comments.
There is couple of methods in UIView that you can override:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; // recursively calls -pointInside:withEvent:. point is in the receiver's coordinate system
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event; // default returns YES if point is in bounds
This should prevent to call touchBegin and other methods.
Regards.
I have a nice solution for this. What ever the area you want to hide the interaction place a transparent button on top of the area.
touchesBegan is a default method so it must call all the time when touch happens on view so there is no way-out, But you can still do one thing set
self.buttonPlayMusic.userInteractionEnabled = FALSE;
for the object you don't need touch may be this could be help you with your desired output.
Have you tried using a UIScrollView as the background ? i.e the area where you do not want touch events to be fired.
UIScrollView does not call the touch methods.
You can add UIImageView Control on that area where you want to disable touch event.you can add UIImageView object as top of self.view subViews.
Example
//area -- is that area where you want to disable touch on self.view
UIImageView *imageView=[[UIImageView alloc]initWithFrame:area];
[self.view addSubView:imageView];
You touchDelegate will always call in this way, but if you are doing some task on touch then you can do your task like this way.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
UIButton *touchObject=(UIButton*)[touch view];
if ([touchObject isKindOfClass:[UIButton class]])
{
//Do what ever you want on button touch
}
else{
return;
}
}

How can you switch from using one UIButton to another while still holding down finger?

Imagine your keyboard. Imagine yourself placing one finger down one key, then (while holding down) moving your finger all the way across to another key on the keyboard. Now, imagine that each key on the keyboard is a UIButton. when you are holding your finger on the current key, this key (UIButton) is highlighted. Then, when the user moves across to another key, the first key is no longer highlighted, and the current key that is pressed down, is highlighted.
Now, I have a 6 x 8 grid of UIButtons each 53 x 53 pixels. So, I have 48 UIButtons. I want to replicate this kind of idea. The button that the users finger is upon, will have a image that is slightly lighter (to look selected like), and all others will will not be slightly lighter.
Here is my idea of how to go about this,
1) Create all 48 UIButtons in viewDidLoad. Add the lighter image to UIControlStateHighlighted for all UIButtons.
2) Add some sort of target for touchUpOutside that somehow makes the current button not highlighted and not usable. (maybe set the highlighted and userInteractionEnabled to no). But then how can I tell the next button to be used? And how can I say that I want the specific UIButton that the users fingers are under to become highlighted and in use to detect gestures and stuff.
Also, this touchUpOutside method may not work because all the buttons are right next to each other, and I think you have to drag far out to run this touchUpOutside.
It's also important to note that the buttons are not placed in equal rows and columns. Sometimes one button will actually be a UIImage but look like a UIButton. So, doing some sort of fast enumeration comparing frames for some reason will not work.
Two observations:
I generally use gesture recognizers for stuff like this, not the various touchUp... methods.
I know you said you don't want a fast enumeration through the subviews, but why not? Just because some are different classes than others is not a problem (because you could just test the isKindOfClass method). (And, as an aside, I'm not sure why some would be buttons and some would not.) Just because they don't line up really makes no difference, either.
Anyway, for stuff like this, I frequently will put the gesture recognizer on the shared parent view (e.g. typically the view controller's view), and then enumerate through the subviews to see in which the current CGPoint is contained?
CGPoint location = [sender locationInView:self.view];
for (UIView *subview in self.view.subviews)
{
if (CGRectContainsPoint(subview.frame, location))
{
// do your appropriate highlighting
if ([subview isKindOfClass:[UIButton class]])
{
// something for buttons
}
else if ([subview isKindOfClass:[UIImageView class]])
{
// something for imageviews
}
return;
}
}
I don't know if any of this makes sense to you, but it seems easiest to me. If you clarify your intent, perhaps I can refine my answer further.
Just as a practical example, you could define a continuous gesture recognizer that kept track of the first and last subview that was clicked on (and if you don't start your gesture on a subview, no gesture is generated, and if you don't stop your gesture on a subview, it cancels the whole thing), e.g.:
#interface SubviewGestureRecognizer : UIGestureRecognizer
#property (nonatomic,strong) UIView *firstSubview;
#property (nonatomic,strong) UIView *currentSubview;
#end
#implementation SubviewGestureRecognizer
- (id) initWithTarget:(id)target action:(SEL)action
{
self = [super initWithTarget:target action:action];
if (self)
{
self.firstSubview = nil;
self.currentSubview = nil;
}
return self;
}
// you might want to tweak this `identifySubview` to only look
// for buttons and imageviews, or items with nonzero tag properties,
// or recursively navigate if it encounters container UIViews
// or whatever suits your app
- (UIView *)identifySubview:(NSSet *)touches
{
CGPoint location = [[touches anyObject] locationInView:self.view];
for (UIView *subview in self.view.subviews)
{
if (CGRectContainsPoint(subview.frame, location))
{
return subview;
}
}
return nil;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
if ([touches count] != 1)
{
self.state = UIGestureRecognizerStateFailed;
return;
}
self.firstSubview = [self identifySubview:touches];
self.currentSubview = self.firstSubview;
if (self.firstSubview == nil)
self.state = UIGestureRecognizerStateFailed;
else
self.state = UIGestureRecognizerStateBegan;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
if (self.state == UIGestureRecognizerStateFailed) return;
self.currentSubview = [self identifySubview:touches];
self.state = UIGestureRecognizerStateChanged;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
self.currentSubview = [self identifySubview:touches];
if (self.currentSubview != nil)
self.state = UIGestureRecognizerStateEnded;
else
self.state = UIGestureRecognizerStateFailed;
}
- (void)reset
{
[super reset];
self.firstSubview = nil;
self.currentSubview = nil;
}
You could then set this up in viewDidLoad:
SubviewGestureRecognizer *recognizer = [[SubviewGestureRecognizer alloc] initWithTarget:self action:#selector(handleTouches:)];
[self.view addGestureRecognizer:recognizer];
And then define your handler as such (this works with buttons and image views, taking advantage of the fact that both support setHighlighted):
- (void)handleTouches:(SubviewGestureRecognizer *)sender
{
static UIControl *previousControl = nil;
if (sender.state == UIGestureRecognizerStateBegan || sender.state == UIGestureRecognizerStateChanged)
{
if (sender.state == UIGestureRecognizerStateBegan)
previousControl = nil;
UIView *subview = sender.currentSubview;
if (previousControl != subview)
{
// reset the old one (if any)
[previousControl setHighlighted:NO];
// highlight the new one
previousControl = (UIControl *)subview;
[previousControl setHighlighted:YES];
}
}
else if (sender.state == UIGestureRecognizerStateEnded)
{
if (previousControl)
{
[previousControl setHighlighted:NO];
NSLog(#"successfully touchdown on %# and touchup on %#", sender.firstSubview, sender.currentSubview);
}
}
else if (sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed)
{
[previousControl setHighlighted:NO];
NSLog(#"cancelled/failed gesture");
}
}
Here is a fairly simple way to do this. Assuming you are creating your buttons programmatically (it would be a huge pain to do this with interface builder). This method works in subclasses of UIViewController, UIView, and UIGestureRecognizer.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//get the touch object
UITouch *myTouch = [touches anyObject];
//get the location of the touch
CGPoint *myPoint = [myTouch locationInView:self.view];
//detect if the touch is in one of your buttons
if ( CGRectContainsPoint(myButton.frame, myPoint){
/*do whatever needs to be done when the button is pressed
repeat the CGRectContainsPoint for all buttons,
perhaps using a while or for loop to look through an array?*/
}
}
This method only detects when the user puts their finger down, you will need to use these methods to detect other movements:
touchesMoved:withEvent detects when the finger moves across the screen without lifting up
touchesEnded:withEvent detects when the finger is lifted off the screen
touchesCancelled:withEvent: detects when something interrupts the app, like receiving a call or locking the screen

Disable touches on UIView background so that buttons on lower views are clickable

Basically, here is my view hierarchy (and I appologize if this is hard to read... I'm new here so posting suggestions happily accepted)
--AppControls.xib
-------(UIView)ControlsView
----------------- (UIView)TopBar
----------------- -------------- btn1, btn2, btn3
----------------- UIView)BottomBar
----------------- --------------slider1 btn1, btn2
--PageContent.xib
----------------- (UIView)ContentView
----------------- --------------btn1, btn2, btn3
----------------- --------------(UIImageView)FullPageImage
My situation is that I want to hide and show the controls when tapping anywhere on the PageContent thats not a button and have the controls show, much like the iPhone Video Player. However, when the controls are shown I still want to be able to click the buttons on the PageContent.
I have all of this working, except for the last bit. When the controls are showing the background of the controls receives the touch events instead of the view below. And turning off user interaction on the ControlsView turns it off on all its children.
I have tried overriding HitTest on my ControlsView subclass as follows which I found in a similar post:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *hitView = nil;
NSArray *subviews = [self subviews];
int subviewCount = [subviews count];
for (int subviewIndex = 0; !hitView && subviewIndex < subviewCount; subviewIndex++){
hitView = [[subviews objectAtIndex:subviewIndex] hitTest:point withEvent:event];
}
return hitView;
}
However, at this point my slider doesn't work, nor do most of the other buttons, and really, things just start getting weird.
So my question is in short: How do I let all the subviews of a view have touch events, while the super view's background is unclickable, and the buttons on views below can receive touch events.
Thanks!
You're close. Don't override -hitTest:withEvent:. By the time that is called, the event dispatcher has already decided that your subtree of the hierarchy owns the event and won't look elsewhere. Instead, override -pointInside:withEvent:, which is called earlier in the event processing pipeline. It's how the system asks "hey view, does ANYONE in your hierarchy respond to an event at this point?". If you say NO, event processing continues below you in the visible stack.
Per the documentation, the default implementation just checks whether the point is in the bounds of the view at all.
Your strategy is to say "yes" when any of your subviews is at that coordinate, but say "no" when the touch would be hitting the background.
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
for (UIView * view in [self subviews]) {
if (view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) {
return YES;
}
}
return NO;
}
Thanks to #Ben Zutto, Swift 3 solution:
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
for view in self.subviews {
if view.isUserInteractionEnabled, view.point(inside: self.convert(point, to: view), with: event) {
return true
}
}
return false
}
Another approach may be to have an invisible full-screen button behind everything else, and take appropriate action when it is hit.
A slight variant on Ben's answer, dealing w/ children which extend outside their parent.
If clipChildren is YES, then this will not return YES for points which are outside the main control but inside some child.
if clipChildren is NO, this is the same as Ben's.
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
BOOL clipChildren = YES;
if (!clipChildren || [super pointInside:point withEvent:event]) {
for (UIView * view in [self subviews]) {
if (view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) {
return YES;
}
}
}
return NO;
}

Hide keyboard when user touches uiview

I have a UIView with multiple text boxes. Now i have used delegates to change the responder from from text field to another. In this case my key board goes away when the user comes to last text field.
but now i want to hide my key board when the user touches UIView(touches any where on screen apart from text boxes). Can some one help me with this.
Thanks
Use resignFirstResponder in touchesBegan, like so:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
if(touch.phase == UITouchPhaseBegan) {
[self.myTextField resignFirstResponder];
}
}
You may need to call this on multiple text fields if you're not sure where the focus is currently located; I haven't tested that case.
Additionally, in Interface Builder, you'll need to enable the "User Interaction Enabled" checkbox for the view, or programatically use:
myView.userInteractionEnabled = YES;
Just call this in your view controller when you want to hide the keyboard.
[self.view endEditing:NO];
I use
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if(touch.phase==UITouchPhaseBegan){
//find first response view
for (UIView *view in [self.view subviews]) {
if ([view isFirstResponder]) {
[view resignFirstResponder];
break;
}
}
}
}
According to Beginning iPhone Development, you draw a round rect button so that it covers your entire UI; the complete screen. Then go to the Layout menu and click Send to Back. Then in the inspector, change the button's type from round rect to Custom. Now add a touch up inside event to this button and attach it to a method which handles it. Within the body of this method, make sure you have the statements:
[myTextFieldOne resignFirstResponder];
[myTextFieldTwo resignFirstResponder];
Basically send the resignFirstResponder message to each of your text fields, or any field that can produce a keyboard.
I'm actually really new to the iPhone SDK. I don't know if this is the best method, but it works and it's what I learned from the aforementioned book. Hope it helps.
A super easy way to do this is working on what PCheese said.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
if(touch.phase == UITouchPhaseBegan) {
[self.view endEditing:YES];
}
}
I previously used [self.view endEditing:YES]; for a button event, but when combined with the previous answer it works a treat. Much easier, and you don't have to do anything else - just put it in your .m file. Also, this works with all (at least, as far as I have seen) text fields (works for UITextField and UITextView).
I know OP probably won't still need this but I just want to share it for others with the same problem.
Thanks Blaenk, I was trying to work out how to do this and didn't realise I could put a button in the background, nice trick! Here's my contribution (new to this site and to Cocoa Touch so it may not be the most robust code ever, but it's working so far...):
I call this method from the touchUpInside event on my UIButton:
-(void)closeKeyboard:(id)sender {
UIView *theFirstResponder = [self findFirstResponder];
if (theFirstResponder) {
[theFirstResponder resignFirstResponder];
}
}
Where this loop finds the firstResponder:
- (UIView *)findFirstResponder {
UIView *firstResponderView = nil;
for (UIView *view in [self entryFields]) {
if ([view isFirstResponder]) {
firstResponderView = view;
break;
}
}
return firstResponderView;
}
It is dependent on each of the UITextField controls in the view having a tag assigned to them (again, can do that in Interface Builder).
My two cents anyway, though i'd better give something back!
SO I agonized over this and I figured it out..
you don't need the other button or anything.
All you need to do is select "Files owner", in the inspector drag from its textField outlet (or whatever you named it) to your actual textfield (via whatever you named it) This will be in addition to whatever inputs you already had wired up.
and ofcourse in addition to the Control outlet (UIview changed to UIControl via inspector) to files owner via backgroundtouched...the first thing we all tried
it work for me
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.view endEditing:NO];
}
only need into self.view have an UItextField
http://objdev.com/2013/11/Dismissing-iOS-Keyboard-Self-View-EndEditing
The most appropriate way of solving this problem is using the following method:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if(![touch.view isMemberOfClass:[UITextField class]]) {
[touch.view endEditing:YES];
}
}
Note: This does not work on UIScrollView instances.
Change the class UIView to class UIControl from the identify tab of inspector.
Add this:
- (IBAction)tabBackground:(id) sender;
to your .h file.
Add this to your .m file:
- (IBAction)tabBackgroup:(id) sender {
[nameField resignFirstRespnder];
[numberField resignFirstResponder];
}
Connect your tabBackground from the inspector, action received section to the UIView (which is an an UIControl) and you're good to go.
For swift 4.0
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch = touches.first
if touch?.phase == UITouchPhase.began {
touch?.view?.endEditing(true)
}
}

Passing touches through a UIView to a UIScrollView not working

I have a view derived from a UIScrollView controller that I use to page through images in a library. That works fine.
I overlayed a UIView on the right side to handle touches for scrolling quickly through the list of images. My problem is that if I pass the touches through to either 'super' or 'nextResponder' they never make it to the UIScrollView object below.
My question is how can I force the UIScrollView below to handle the touches that I don't need to handle? I'm setting a timer for 0.3 seconds that during that time all touches are passed to the UIScrollView to handle. So if the user started a swipe gesture to turn the page, it will happen.
Here's the code for the touchesBegan method:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
// Start a timer to trigger the display of the slider and the processing of events.
touchesTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:#selector(showSlider:) userInfo:nil repeats:NO];
// Where are we at right now?
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
lastPage = [self page:currentPoint.y];
// Pass the event though until we need it.
// [self.nextResponder touchesBegan:touches withEvent:event];
if ([touch.view isKindOfClass:[UIScrollView class]])
{
if (self.nextResponder != nil &&
[self.nextResponder respondsToSelector:#selector(touchesEnded:withEvent:)])
{
[self.nextResponder touchesEnded:touches withEvent:event];
}
}
}
I would try using a regular UIViewController rather than a UIScrollViewController and then add the scroll view object where you need it and put the scroll faster view you want on the right side. This way they are separate and the touches won't get confused.
Here's an easier solutions that worked well for me:
In the UIView on top of the UIScrollview make the width and height both 0 (so that the view is no longer technically on top of the UIScrollView) and set clipsToBounds = NO (so that the contents of the view still show up on top of the UIScrollView).
self.OverlayView.clipsToBounds = NO;
CGRect frame = self.OverlayView.frame;
self.OverlayView.frame = CGRectMake(frame.origin.x, frame.origin.y, 0, 0);
Note that if the UIView contains interactive controls then they will no longer work. You'll need to move it into it's own view above the UIScrollView.