首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swift:旋转车轮概念中的子视图的userInteractionEnabled

Swift:旋转车轮概念中的子视图的userInteractionEnabled
EN

Stack Overflow用户
提问于 2017-12-29 20:40:39
回答 1查看 384关注 0票数 1

我正在尝试iOS中的旋转轮概念。我的基础教程是here

UIControl是这里的核心。Superview的userinteraction始终处于禁用状态。

那么如何为它的子视图单独启用userinteraction呢?

我已经在SmallRoundViews中添加了UITapGestureRecognizer。手势不起作用。

如果我将superview的用户交互更改为启用,则手势可以正常工作。但是,它并没有旋转。

如果我将superview的用户交互更改为禁用,则旋转正在工作。但是手势不起作用。

我需要把所有事情都做完。你能给我指路吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-02 00:20:11

以下代码是有效的,

如果我将superview的userinteraction更改为trueUITapGestureRecognizerspinning都可以工作。

重写UIControl子类中的UITouch方法。

代码语言:javascript
复制
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

        let touch : UITouch = touches.first!
        self.beginTracking(touch, with: event)
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {

        let touch : UITouch = touches.first!
        self.continueTracking(touch, with: event)
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {

        let touch : UITouch = touches.first!
        self.endTracking(touch, with: event)

}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48022776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档