gpt4 book ai didi

ios - UIControl 事件之间的区别

转载 作者:行者123 更新时间:2023-11-29 11:55:15 26 4
gpt4 key购买 nike

Documentation of UIControl Class :

UIControlEventTouchDragInsideUIControlEventTouchDragEnterUIControlEventTouchUpInside 有什么区别?一切似乎都一样。

最佳答案

不,这些都不一样。尽管它们都来自 UIControl

Apple 在 struct 中为 swift 和 Objective-C 在 enum 中提供了这些东西。这两个都在 UIControlEvents 中。以下是您可能会看到的 structenum

struct UIControlEvents : OptionSetType { //This is for Swift.
init(rawValue rawValue: UInt)
static var TouchDown: UIControlEvents { get }
static var TouchDownRepeat: UIControlEvents { get }
static var TouchDragInside: UIControlEvents { get }
static var TouchDragOutside: UIControlEvents { get }
static var TouchDragEnter: UIControlEvents { get }
static var TouchDragExit: UIControlEvents { get }
static var TouchUpInside: UIControlEvents { get }
static var TouchUpOutside: UIControlEvents { get }
static var TouchCancel: UIControlEvents { get }
static var ValueChanged: UIControlEvents { get }
static var PrimaryActionTriggered: UIControlEvents { get }
static var EditingDidBegin: UIControlEvents { get }
static var EditingChanged: UIControlEvents { get }
static var EditingDidEnd: UIControlEvents { get }
static var EditingDidEndOnExit: UIControlEvents { get }
static var AllTouchEvents: UIControlEvents { get }
static var AllEditingEvents: UIControlEvents { get }
static var ApplicationReserved: UIControlEvents { get }
static var SystemReserved: UIControlEvents { get }
static var AllEvents: UIControlEvents { get }
}


typedef enum UIControlEvents : NSUInteger { //This is for Objective-C.
UIControlEventTouchDown = 1 << 0,
UIControlEventTouchDownRepeat = 1 << 1,
UIControlEventTouchDragInside = 1 << 2,
UIControlEventTouchDragOutside = 1 << 3,
UIControlEventTouchDragEnter = 1 << 4,
UIControlEventTouchDragExit = 1 << 5,
UIControlEventTouchUpInside = 1 << 6,
UIControlEventTouchUpOutside = 1 << 7,
UIControlEventTouchCancel = 1 << 8,

UIControlEventValueChanged = 1 << 12,
UIControlEventPrimaryActionTriggered = 1 << 13,
UIControlEventEditingDidBegin = 1 << 16,
UIControlEventEditingChanged = 1 << 17,
UIControlEventEditingDidEnd = 1 << 18,
UIControlEventEditingDidEndOnExit = 1 << 19,

UIControlEventAllTouchEvents = 0x00000FFF,
UIControlEventAllEditingEvents = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved = 0xF0000000,
UIControlEventAllEvents = 0xFFFFFFFF
} UIControlEvents;

现在来谈谈苹果对这件事单独做的理论解释。顺便说一句,我不是在解释所有事件,而是只接受您的要求。

  1. UIControlEventTouchDragEnter - 手指被拖入控件边界的事件。(我希望您知道 framesbounds 之间的区别)

  2. UIControlEventTouchDragInside - 手指被拖动到控件边界内的事件。

  3. UIControlEventTouchUpInside - 手指位于控件边界内的控件中的触摸弹起事件。

    从 iOS 2.0 开始,这些都可用。查看 TouchUpTouchDrag 之间的区别,这将帮助您清楚地了解这件事。

谢谢,希望这对您有所帮助。

关于ios - UIControl 事件之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39384573/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com