我的今日小部件在下拉通知中心后需要0到5秒才能显示出来。一旦我稍微往上移动通知中心,我的小部件就会再次消失。
一旦小部件可见,一切都正常。
我错过了什么吗?
override func viewDidLoad() {
super.viewDidLoad()
self.locationManager.delegate = self
if (self.locationManager.respondsToSelector(Selector("requestWhenInUseAuthorization"))){
self.locationManager.requestWhenInUseAuthorization()
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
self.locationManager.startUpdatingLocation()
imageViewCheck.layer.cornerRadius = 5.0
self.getLocation()
}
func getLocation() -> Bool{
var test = self.locationManager.location
if test != currentLocation {
currentLocation = test
return true
} else {
return false
}
}
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
var newLocation = self.getLocation()
if (newLocation) {
completionHandler(NCUpdateResult.NewData)
} else {
completionHandler(NCUpdateResult.NoData)
}
}