将事件从UIScrollView转发到UIButton

时间:2011-05-16 16:02:29

标签: iphone ios uiscrollview uibutton touch

我在UIButton内有一个UIScrollView。问题是UIButton不足以填满整个UIScrollView。我希望能够将UIScrollView的其他区域中的触摸事件转发到UIButton。这是我的应用程序的屏幕截图:

http://imageshack.us/photo/my-images/405/img1410.png/

有谁知道怎么做?

3 个答案:

答案 0 :(得分:1)

[button addTarget:self action:@selector(itemTouched:)forControlEvents:UIControlEventTouchUpInside];

- (void) itemTouched:(UIButton*) sender
{
  [self performSelectorOnMainThread:@selector(doSomething:) withObject:sender waitUntilDone:NO];
}

UIButton的重点可以在调用doSomething方法之前显示。

答案 1 :(得分:0)

我不确定你能以这种方式转发,但我想你可以调整UIButton的大小以填充整个scrollView并使内容不会拉伸,这样看起来相同,但是会有更大的的UIButton。

答案 2 :(得分:0)

要将链中的触摸传播到子视图,请使用:

[mychild touchesBegan:touches withEvent:event];
在你的scrollView的touchesBegan中