理解 Objective c 枚举声明
来自 iPhone UIControl
UIControlEventAllTouchEvents = 0x00000FFF,
UIControlEventAllEditingEvents = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved = 0xF0000000,
UIControlEventAllEvents = 0xFFFFFFFF
现在我假设 UIControlEventApplication 是我可以用来指定自定义控件事件的“范围”,但我不知道如何正确执行它。 仅当我分配 0xF0000000 时,控制事件才会正确触发。 如果我分配其他任何内容(0xF0000001),控制事件就会在不应该的情况下触发。
一些澄清:
enum {
UIBPMPickerControlEventBeginUpdate = 0x0F000000,
UIBPMPickerControlEventEndUpdate = // Which value do I use here?
};
我对它是一个范围的假设是基于文档。 其中说:
我这么认为是因为文档说:可供应用程序使用的一系列控制事件值。
谁能帮助我理解 UIControl 中使用的枚举声明的类型?
From iPhone UIControl
UIControlEventAllTouchEvents = 0x00000FFF,
UIControlEventAllEditingEvents = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved = 0xF0000000,
UIControlEventAllEvents = 0xFFFFFFFF
Now I assume the UIControlEventApplication is the 'range' I can use to specify custom control events, but I have no idea how to do it properly. Only if I assign 0xF0000000 the control event will correctly fire. If I assign anything else (0xF0000001) the control event fires when it's not supposed to.
Some clarification:
enum {
UIBPMPickerControlEventBeginUpdate = 0x0F000000,
UIBPMPickerControlEventEndUpdate = // Which value do I use here?
};
My assumption of it being a range is based on the docs. Which say:
I assume this because the docs say: A range of control-event values available for application use.
Could anyone help me understand the type of enum declaration used in UIControl?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 0x0F000000 是您可以用来创建自己的控制事件的 4 位。
因此,以下任意组合:
您当然可以将这些组合在一起以创建新的:
因此在您的示例中:
I would think 0x0F000000 is the 4 bits you have at your disposal for creating your own control events.
So any combination of:
You can of course OR these together to create new ones:
So in your example:
要使用枚举,您只需执行按位运算:
To use the enums you just do bitwise operations: