【问题标题】:Forward events from UIScrollView to UIButton将事件从 UIScrollView 转发到 UIButton
【发布时间】:2011-05-16 16:02:28
【问题描述】:

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

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

有人知道怎么做吗?

【问题讨论】:

  • iOS(iPhone、iPod touch 和 iPad)

标签: iphone ios uiscrollview uibutton touch


【解决方案1】:
[button addTarget:self action:@selector(itemTouched:)forControlEvents:UIControlEventTouchUpInside];

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

UIButton 的高亮可以在调用doSomething 方法之前显示。

【讨论】:

    【解决方案2】:

    我不确定您是否可以通过这种方式转发触摸,但我想您可以调整 UIButton 的大小以填充整个 scrollView 并使内容不拉伸,使其看起来相同,但会更大用户界面按钮。

    【讨论】:

      【解决方案3】:

      要将触地链向下传播到子视图,请使用:

      [mychild touchesBegan:touches withEvent:event];
      

      在你的 scrollView 的 touchesBegan 中。

      【讨论】:

        猜你喜欢
        • 2011-04-13
        • 1970-01-01
        • 2020-08-07
        • 2010-12-27
        • 1970-01-01
        • 2012-02-08
        • 2017-01-14
        • 1970-01-01
        • 2020-05-31
        相关资源
        最近更新 更多