platform :ios, '7.0'
pod "AmbientStatus", "~> 0.1.0"
platform :ios, '7.0'
pod "AmbientStatus/ASTransitMonitor"
首先,将 <ASTransitMonitorDelegate>
添加到您希望使用的任何文件中。
完成之后,您需要 startMonitoring
用户的旅行
ASTransitMonitor *transitMonitor = [ASTransitMonitor sharedInstance]; // create new instance
transitMonitor.delegate = self; // assign the delegate to self
[transitMonitor startMonitoring]; // start monitoring the user's transit
在创建新的 sharedInstance
的 ASTRansitMonitor 并设置 delegate
之后,您可以按需实现以下可选委托
- (void)transitMonitor:(ASTransitMonitor *)transitMonitor didChangeTransitState:(ASTransitState)transitState {
// Do something if the user starts driving here (or has changed transit)
}
- (void)transitMonitor:(ASTransitMonitor *)transitMonitor didChangeSpeed:(CGFloat)newSpeed oldSpeed:(CGFloat)oldSpeed{
// Do something if the user has sped up here
}
- (void)transitMonitor:(ASTransitMonitor *)transitMonitor didAccelerationChange:(CMAcceleration)acceleration{
// Do something if the user started shaking the device here
}
更多帮助,请参阅 文档。
ASTransitMonitor 从 SOMotionDetector(尽管非逐字)中吸取了大量的代码,获得了 许可,该软件由 Artur Mkrtchyan (arturdev) 为 SocialObjects Software 开发。
项目的其余部分由 Rudd Fawcett 开发。您可以在 GitHub 上找到他的所有开源项目。
打开问题。我会尽量在 24 小时内回复您。
AmbientStatus 和 ASTRansitMonitor 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。