I got an UIButton
inside an UIScrollView
. The problem is that the UIButton
is not big enough to fill the entire UIScrollView
. I'd like to be able to forward开发者_JS百科 the touch events in other areas of the UIScrollView
to the UIButton
. Here's a screenshot of my app:
http://imageshack.us/photo/my-images/405/img1410.png/
Does anyone knows how to do that?
[button addTarget:self action:@selector(itemTouched:)forControlEvents:UIControlEventTouchUpInside];
- (void) itemTouched:(UIButton*) sender
{
[self performSelectorOnMainThread:@selector(doSomething:) withObject:sender waitUntilDone:NO];
}
The highlight of UIButton
can be shown before call doSomething
method.
I'm not sure you can forward touches in that manner, but I guess you could resize the UIButton to fill the whole scrollView and make the content not stretch, such that it looks identical, but there'd be a much bigger UIButton.
To propagate touches down the chain to a sub view use:
[mychild touchesBegan:touches withEvent:event];
in your scrollView's touchesBegan.
精彩评论