gpt4 book ai didi

objective-c - 来自字符串的 UIControlEvents 变量

转载 作者:行者123 更新时间:2023-11-28 22:51:06 28 4
gpt4 key购买 nike

是否可以创建 UIControlEvents来自 NSString 的变量或类似的?例如,我可能有一个 NSString那叫UIControlEventTouchUpInside这与 UIControlEvents 的类型定义之一相同变量。

感谢大家的帮助!

最佳答案

如果我理解这是如何正确工作的,UIControlEvents 的枚举如下:

enum {
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,

UIControlEventEditingDidBegin = 1 << 16,
UIControlEventEditingChanged = 1 << 17,
UIControlEventEditingDidEnd = 1 << 18,
UIControlEventEditingDidEndOnExit = 1 << 19,

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

再一次,如果我理解正确的话,请纠正我,但你应该能够创建一个变量整数并将其传递给控制事件,如下所示:

    int myVariable = 64;
[myButton addTarget:self action:@selector(mySelector) forControlEvents:myVariable];

有关 Bitwise Shift Left 的说明,请参阅此链接

关于objective-c - 来自字符串的 UIControlEvents 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11993516/

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