madewulf
madewulf

Reputation: 1910

UIbutton taking time to receive down event in a UISCrollView on iOS5

I have the following hierarchy:

- UIView 1
  - UIScrollView 2
    - UIView 3
      - UIView 4
        - UIButton 5 

My problem is that the touch down on the UIButton requires me to press for what seems a long time (like a second) to be registered by the UIButton.

The way this hierarchy is created : UIView1 is loaded from a nib file with 2 and 3 embedded but 4 is created from another nib file, first placed in one view not depicted here and then brought in 3 using addsubview. (I don't know if this is relevant).

Does somebody have any idea on how to fix this delay ? The problem appears on my 4s with ios5.1 and not in the simulator with iOS 6.

Upvotes: 0

Views: 217

Answers (2)

Sharanya K M
Sharanya K M

Reputation: 1805

Try to set UIScrollView delaysContentTouches property to NO.

OR

Try using [button performSelector:@selector(buttonClickMethod:) afterDelay:0.0];

Upvotes: 1

Anand
Anand

Reputation: 1973

@interface CustomScrollView : UIScrollView {

}

@end

@implementation CustomScrollView


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

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [[self superview] touchesEnded:touches withEvent:event];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [[self superview] touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

    [[self superview] touchesMoved:touches withEvent:event];

}

- (void)dealloc {
    [super dealloc];
}


@end

Use customscrollview Instead of uiscrollview

Upvotes: 0

Related Questions