【问题标题】:How to pass touch event to another object?如何将触摸事件传递给另一个对象?
【发布时间】:2012-02-20 10:09:43
【问题描述】:

我提到了名为“Comic Strip”和“Balloon Stickies Free”的应用

当我添加一个语音气球并触摸 s.b 或 s.b 的尾巴时,它会起作用。但是当我在 s.b 和 s.b 的尾巴周围或之间触摸尾巴时,它不起作用。并且 Photo 得到接触并在 s.b. 下工作

所以我尝试使用hitTest:withEvent.

当我第一次触摸矩形或 tailRect 时它可以工作。但是当我触摸对象中的其他地方时,我再次触摸矩形或tailRect,它就不起作用了。

那么如何修改这段代码呢?我不知道..请帮帮我

- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *hitView = [super hitTest:point withEvent:event];

    if(CGRectContainsPoint(rectangle, currentPt)==YES || CGRectContainsPoint(tailRect, currentPt)==YES)
        return hitView;
    else
        return nil;
}

【问题讨论】:

    标签: iphone ios events touch


    【解决方案1】:

    尝试改写- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

    或者看看Ole Begemann's OBShapedButton。代码可以轻松修改 使用 UIView 而不是 UIButton。

    【讨论】:

      【解决方案2】:

      请参阅此帖子horizontal scrolling。使用此代码,您可以在单个 UIWindow 类中获取所有触摸事件。您必须编写一些代码来适当地传递控制权。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-09
        • 2023-03-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多