【问题标题】:UITouch not return the correct positionUITouch 没有返回正确的位置
【发布时间】:2012-06-07 11:31:39
【问题描述】:

我有问题...

我想在主视图下方的单个视图中获取 UITouch 位置。

我的代码是:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint previous = [[touches anyObject] previousLocationInView:toolBarView];
    CGPoint current = [[touches anyObject] locationInView:toolBarView];
}

问题在于它返回的是任何视图中的位置,而不是工具栏视图。

怎么了?

【问题讨论】:

    标签: iphone xcode uitouch


    【解决方案1】:

    你可能想更正

    CGPoint current = [[touches anyObject] locationInView:toolBarView];
    

    到:

    CGPoint current = [[touches anyObject] locationInView:[toolBarView view]];
    

    【讨论】:

    • 谢谢,我已经解决了。未为 toolBarView 启用用户交互。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    相关资源
    最近更新 更多