Hi all,
Can anyone tell me why the following code works perfectly when it runs the first time, or when the app reloads? It does not however change the VC background image, although I can see it step through the code. The image does load correctly when the app is swiped away and reloaded.
I am stumped. Any thoughts would be much appreciated.
Blessings, --Mark
Can anyone tell me why the following code works perfectly when it runs the first time, or when the app reloads? It does not however change the VC background image, although I can see it step through the code. The image does load correctly when the app is swiped away and reloaded.
I am stumped. Any thoughts would be much appreciated.
Blessings, --Mark
Code Block if CacheManager.getIsUserBackGround() { //get a refrerence to the the documents for the app let fileManager = FileManager.default //get the path from Constants let imagePath = Constants.getImage() //check if not nil, and if not set the background pict if imagePath != "" { if fileManager.fileExists(atPath: imagePath!) { DispatchQueue.main.async { let backgroundImage = UIImageView(frame: UIScreen.main.bounds) backgroundImage.image = UIImage(contentsOfFile: imagePath!)! backgroundImage.contentMode = UIView.ContentMode.scaleAspectFill self.view.insertSubview(backgroundImage, at: 0) } }else{ DispatchQueue.main.async { print("error") // Alerts.showAlert(title: "Attention", message: "A user selected image from the Photos Library has not been saved. \n \n Tap the Gear icon on the 'Lists' screen and select the 'Set background from Photos' option to save an image.", vc: self) } } }
I make things WAY harder than they need to be!
I discovered that I was adding a view (and the memory overhead) each time I changed the image and when the app reset, it just used the last image saved.
The simple solution was to ignore the background view and add a UIImageView and change the image to that! Live and learn!
I discovered that I was adding a view (and the memory overhead) each time I changed the image and when the app reset, it just used the last image saved.
The simple solution was to ignore the background view and add a UIImageView and change the image to that! Live and learn!