I want to achieve a rather simple effect. A scrollView and a static button above it. So far not problem. Unfortunately a problem occurs if I want to scroll the view "trough" the button. So start dragging inside the button will effect the button, not the scroll view.
Any ideas on how to achieve that?
Thanks a lot!
I think this approach won't work because touchesBegan is deprecated in UIScrollView … (Is this info true?)
Not the solution :-)
@implementation MySuperButton
+ (id)buttonWithFrame:(CGRect)frame {
return [[[self alloc] initWithFrame:frame] autorelease];
}
- (id)initWithFrame:(CGRect)frame {
if (self == [super initWithFrame:frame]) {
NSLog(@"initWithFrame");
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.nextResponder touchesBegan:touches withEvent:event];
NSLog(@"[self nextResponder]: %@", [self nextResponder]);
}
@end
Unfotunately this does not work, yet. I think the next responder is a my UIView not my UIScrollView. Any ideas?
If my viewcontroller which is the nextResponder, passes the touches to the scrollView, nothing happens aswell.
Add the button not to the scroll view but to its parent view, and everything should work just fine. Touches on the button directly will get delivered to the button, and touches on the background (scroll view) will get delivered to the scroll view.
As the button isn't a subview of the scroll view it won't move with the background (which I suppose you mean with static).
I never played alot with the touch events and such, but i'll try to help with my basic understanding anyway.
Try setting the button's exclusiveTouch to NO. Not sure, but maybe enableMultitouch to YES as well.
If that doesn't work i'd try maybe subclassing UIButton, overriding the touch events and passing them to [self nextResponder] before/after [super touchEventX:]?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With