gpt4 book ai didi

ios - 跟踪 iOS 应用程序的任何用户交互

转载 作者:可可西里 更新时间:2023-11-01 00:20:46 25 4
gpt4 key购买 nike

如何跟踪或捕捉我的 iOS 应用的每次用户交互?就像按下 UIButton、UIBarButton ……任何 UIControl 元素一样。

我知道有数百种分析工具,如 Google Analytics、Flurry、Appsee 等,但我想将这些数据保存在我自己的服务器上。

最佳答案

您可以子类化 UIApplication:

  • 创建一个 UIApplication 子类
  • 覆盖sendAction(_ action: Selector, to target: Any?, from sender: Any?, for event: UIEvent?)事件方法,记得调用super实现
  • 在实现中放入 NSLog 或其他诊断代码

例如,这将在每次按下 UIButton 时打印一条日志:

func sendAction(_ action: Selector, to target: Any?, from sender: Any?, for event: UIEvent?) -> Bool {
if (sender is UIButton) {
print("Action: \(NSStringFromSelector(action)) - \(target) - \(sender)")
}
return super.sendAction(action, to: target, from: sender, for: event)
}


2017-07-08 14:46:18.270 UIApplicationSubclass[94764:c07] Action: anAction: - <ViewController: 0x76790a0> - <UIRoundedRectButton: 0x767b9b0; frame = (103 66; 73 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0x767bad0>>
2017-07-08 14:46:27.378 UIApplicationSubclass[94764:c07] Action: anAction: - <ViewController: 0x76790a0> - <UIRoundedRectButton: 0x767b9b0; frame = (103 66; 73 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0x767bad0>>

对于 objective-c 引用 click here

关于ios - 跟踪 iOS 应用程序的任何用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47413251/

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