【问题标题】:how to detect touch on UIView with UIimage ontop of it?如何检测 UIView 上带有图像的触摸?
【发布时间】:2010-04-16 20:58:15
【问题描述】:

我想在其上使用 UIview 和 UIImage 以及文本框和按钮我希望用户在触摸 UIview 或视图中的任何内容时拖动它,实现此方法的最佳方法是什么?

UIView 位于单个 View Controller 上,并使用 Interface Builder 制作我的 UIviews 和 UIimages。

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    查看 Apple 示例“MoveMe”http://developer.apple.com/iphone/library/samplecode/MoveMe/Introduction/Intro.html

    里面的MoveMeView类是可拖动的。 (还有一些多余的动画在进行,但拖动是有的)。

    【讨论】:

      【解决方案2】:

      你需要继承UIView并实现

      - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event,

      - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event,

      - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event,和

      - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多