My today widget takes between 0 and 5 seconds to show up after pulling down the notification center. As soon as I move up my notification center a bit, my widget disappears again.
Once the widget is visible, everything works fine.
What am I missing?
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)
}
}
Solved:
After hours of not finding anything I decided to delete my whole Code and put it back together piece by piece. Unfortunately the problem was still there without any code left. After checking all Layout constraints without finding any error I deleted the widget and added a new one.
And guess what? It worked... It seemes like xCode didn't like my experimenting with the layout and had something messed up where I could not fix it. After adding the new widget and reproducing my old one with the exact same constraints and code everything worked perfectly.