我的位置服务有问题.我无法设置一个功能,通过NSTimer在后台更新我的位置坐标.这是来自appDelegate的代码:
var locationManager = CLLocationManager()
func applicationDidEnterBackground(application: UIApplication) {
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.theTimer = NSTimer(fireDate: NSDate(), interval: 40, target: self, selector: "handleTimer", userInfo: nil, repeats: true)
NSRunLoop.currentRunLoop().addTimer(self.theTimer, forMode: NSDefaultRunLoopMode)
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
var locValue:CLLocationCoordinate2D = manager.location.coordinate
println("dinBack = \(locValue.latitude) \(locValue.longitude)")
self.locationManager.stopUpdatingLocation()
}
func handleTimer(){
println("started")
self.locationManager.startUpdatingLocation()
}
Run Code Online (Sandbox Code Playgroud)
PS. - 当然,我已经导入了重置. - 当我回到应用程序时,控制台会打印出应该在后台打印的内容.
我已经尝试了几乎所有的东西,我无法理解在后台模式下收到新通知时如何打开手机屏幕.
我正在使用FCM.当应用程序处于后台时,收到的通知由系统托盘管理.当收到新内容时,如何让系统托盘打开屏幕?谢谢!
android push-notification android-notifications firebase firebase-cloud-messaging
有没有办法从UITextView添加目标到指定的单词?例如.我想从UITextView中添加一个带有哈希标记的单词的目标.我正在使用一个函数从textview获取带有哈希标记的单词的数组,但我不知道如何将它们添加到目标或点击手势.