我希望我能说清楚。我有按钮,我想知道什么对象中的什么函数是它的 .touchDown 事件的目标。iOS 中有一些属性和功能可能是我正在寻找的,但我无法让它们工作。属性为:self.allTargets 函数为:self.actions(forTarget:, forControlEvent:)
我已经用这段代码打印了这些值:
print( self.allTargets )
print( self.actions(forTarget: self, forControlEvent: .touchDown) ?? "no targets")
print( self.actions(forTarget: Button_Test.ViewController , forControlEvent: .touchDown) ?? "no targets")
print( self.actions(forTarget: "ViewController", forControlEvent: .touchDown) ?? "no targets")
结果:
[AnyHashable(<Button_Test.ViewController: 0x7b293300>)]
no targets
no targets
no targets
我可以看到按钮有一个目标,但我无法获得该功能。帮助!