cost 131 ms
如何在代码中为自定义 NSControl 定义操作? - How do I define an action for a custom NSControl in code?

我创建了NSControl的子类,它是数字格式的NSTextField和NSStepper的组合。 这是基本代码: 如果我创建一个实例并将其作为子视图添加到我的主视图中,这将按预期工作:我可以单击步进按钮来更改值,我可以直接输入一个数字。 但是,我不知道如何定义将通知我的目标(超级视图)任何更改的 ...

如何为自定义 UIControl 设置 primaryActionTriggered? - How do I set primaryActionTriggered for a custom UIControl?

我创建了一个自定义 UIControl。 最接近的比较是 UIStepper 但它是 UIControl 的子类,因为它完全是自定义的。 对于大多数 UIControls,您可以使用primaryActionTriggered创建目标操作,以避免需要知道哪些操作很重要。 我想为我的自定义 UICo ...

Swift UITextField 目标动作作为关闭,不删除目标动作的问题 - Swift UITextField target-actions as closure, problem with not removing target-actions

我对Eric Armstrong的代码做了一些修改 将闭包作为目标添加到 UIButton 但是这两个代码都有问题。 来自 Eric 的那些确实删除了所有目标操作 另一方面,修改后的代码根本不会删除目标操作。 当然是 if 条件造成的,但也意味着 Storable 属性中没有正确存储目标。 我的目标 ...

如果在添加范围之外创建barBarttonItem,为什么无法添加它呢? - Why adding barBarttonItem won’t work if created out of scope where it’s added?

添加barButtons时遇到了一些问题,并在另一个问题的答案中找到了解决方案,但是它没有解释为什么必须在同一范围内创建和添加按钮。 我想知道为什么您不能在类级别创建按钮并将其添加到诸如viewDidLoad之类的方法中。 对于下面复制的该问题无效的示例代码: 这将导致无法识别@ob ...

CATransform3DMakeTranslation后无法调用NSButton - NSButton not callable after CATransform3DMakeTranslation

我有一个奇怪的问题,从未在iOS上见过,但出现在macOS Swift开发中。 我有一个NSButton ,它通过addSubview方法添加到自定义NSView 。 该按钮具有目标功能。 将其添加到customView无法单击该按钮。 如果我将其添加到全局“视图”中,则可以直接正常 ...

编程创建UIButton事件时@objc和IBAction之间的任何差异? - Any differences between @objc and IBAction when programmatically creating UIButton event?

当从故事板中的UIButton创建一个事件处理程序时,Swift在func之前添加@IBAction 。 当以编程方式将事件添加到UIButton到func ,Swift会出错并说我需要在我的方法前添加@objc ,但是当我添加@IBAction ,它也会编译。 2,我在以编程方式向UI ...

当UIButton未产生事件时,是否可以使用委托发送消息? - Is it possible to use a delegate to send a message when the event is not produced by a UIButton?

我想知道如何使用委托从名为MotionListener的类向MyViewController发送时钟消息,但是在将Apple对target-action的解释转换为可行命令时遇到了麻烦。 目标动作是一种设计模式,其中,一个对象保存事件发生时向另一个对象发送消息所需的信息。 存储的信息 ...

CoreMotion [ViewController updateReferenceAttitude:]-为什么无法识别选择器? - CoreMotion [ViewController updateReferenceAttitude:] - why is the selector not recognised?

我是CoreMotion 。 我的第一个程序显示deviceManager更改俯仰,滚动和偏航的值,但是在尝试设置referenceAttitude时崩溃 在调试中,我方法中的语句 崩溃与以下 为了进行测试,我将Xcode 8.3.3与运行iOS 10.3.3的iPho ...

成员引用基本类型“类”不是结构或联合体-Fixit是否已将我引向正确的方向? - Member reference base type 'Class' is not a structure or union - has the Fixit led me in the right direction?

我正在尝试创建一个delegate ,该delegate将在名为SGView的自定义UIView从UIButtons发送消息,而在出现错误消息之后,我的SGView还有些不足。 我最近学习了如何从实例方法内部获取委托以成功发送消息 。 SGView包含一个类方法,该类方法将多个UIBut ...

为什么UIButton使用目标动作设计模式而不是UITextField的委派模式和反之 - Why UIButton uses Target Action Design Pattern not Delegate Pattern and Vice Versa for UITextField

有谁能帮助我们理解为什么Apple决定使用Target Action设计模式来处理UIButton而不是Delegate Pattern? 或者,我可以说为什么Apple为UITextField选择委托设计模式,甚至同样的事情也可以通过Target Action来实现。 ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM