Take the 2-minute tour ×

I have a UIButton behind a UIScrollView. The scroll's background is transparent and the button is in the lower right corner. So it is visible.

The problem is that the UIButton does not respond to any touch events when it is below the scroll. What would it require to make it respond to touch events in this scenario?

Thank you

share|improve this question
Why don't you just put the UIButton on top of the UIScrollView? –  titaniumdecoy Sep 7 '11 at 0:46

7 Answers 7

up vote -3 down vote accepted

Actually you can do this, I have done it on the Mac, had to do with passing down the events. Search online you should be able to find some pointers. I remember it took me a while to solve it a while back.

share|improve this answer

You should use the +touchesBegan method to pass on the touches to the next object.
Here is a example of how you would do this:

printf("MyButton touch Began\n");
[self.nextResponder touchesBegan:touches withEvent:event]; 

Heres some more info on the responder chain:

  1. A Bit About the Responder Chain (http://iphonedevelopment.blogspot.com)

  2. Cocoa Application Competencies for iOS: Responder Object (http://developer.apple.com)

share|improve this answer

If the UIButton is behind the UIScrollView, then it cannot respond to touches because there is a UIScrollView in the way! Put the UIButton on the UIScrollView or shrink the UIScrollView so that it no longer obstructs the button.

share|improve this answer
But I need the button stationary and BEHIND the Scroll, when the scroll moves –  vgr Sep 6 '11 at 23:58
@vgr: Well, you can't have your cake and eat it, too. The front view blocks the back view. That's how it works. –  PengOne Sep 7 '11 at 0:36
But it has completely transparent background –  vgr Sep 7 '11 at 0:41
@vgr, that makes no difference. –  titaniumdecoy Sep 7 '11 at 0:46

Maybe a better approach is to put a UIView subclass (instead of a UIButton) as subview on UIScrollView and add a UITapGestureRecognizer on them.

share|improve this answer
If you make the UIView a subview of the UIScrollView then it will move together with the scroll. I need the button/UIView to be stationary. –  vgr Sep 6 '11 at 23:59
OK, only try [parentViewOfButton bringViewToFront:uibutton]; –  D33pN16h7 Sep 7 '11 at 0:07

You can try this. U need to add the button to the subview after you add your scrollview.


[myView addSubview:myScrollView];


[myView addSubview:myButton];

If you do it in IB, u just need to drag you button below your scrollview...

share|improve this answer

For newbies like me who come to look for help, here is how you do it in Storyboard: drag the button to the same level as the scrollView, and make sure the button is BELOW the scrollView - the order matters! The lower the position, the topper the view layer is

share|improve this answer

I had this problem today, after much time investigating is pretty difficult to achieve, because you can lose the dragging ability in exchange for the buttons click event.

However: I ended up with this, a UIScrollView subclass whose receives the button or buttons to which it is interested in catching the event.

The key is to use [(UIControl*)view sendActionsForControlEvents: UIControlEventTouchUpInside];, because calling touchesBegan method not always works as expected. This won't change the GUI as you press the button but you can implement that as needed in a custom method.

@implementation ForwardScrollView

@synthesize responders = _responders;

- (id)initWithFrame:(CGRect)frame
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _touchesEnabled = YES;
    return self;

- (id)initWithCoder:(NSCoder *)aDecoder {
    if ( self = [super initWithCoder: aDecoder]) {
        _touchesEnabled = YES;
    return self;

    return _touchesEnabled;

    _touchesEnabled = NO;
    UIWindow *window = [UIApplication sharedApplication].delegate.window;
    for(UITouch *touch in touches) {
        CGPoint point = [touch locationInView:self];
        point = [window convertPoint:point fromView:self];
        UIView *view = [window hitTest:point withEvent:event];

        UITouch* touch = [touches anyObject];
        UIGestureRecognizer* recognizer;
        if ([touch gestureRecognizers].count > 0) {
            recognizer = [touch gestureRecognizers][0];

        if ( (!recognizer || ![recognizer isMemberOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")])  && [_responders containsObject: view]) {
            [(UIControl*)view sendActionsForControlEvents: UIControlEventTouchUpInside];

    _touchesEnabled = YES;



The counting on the gestureRecognizers is to avoid the pan gesture that could trigger the button when no real tap is made.

share|improve this answer

Your Answer


