Snapshot snapshot that has not been rendered results in blank snapshots when the image is rendered modally - Swift 3

I have a Table View Controller as a tab. It has a button that will take you to your Facebook profile:

func didTapFacebook() {
        let url = URL(string: "http://www.facebook.com/" + myFacebookId)
        if UIApplication.shared.canOpenURL(url!) {
            UIApplication.shared.open(url!, options: [:], completionHandler: nil)
        }
    }

      

Works well with every button press. Another tab has a button that is a navigation controller with a Table View controller as its root:

func segueToTable(_ sender: UIViewController, tvc: MyTableViewController, completion: @escaping ((_ done: Bool) -> Void)) {
        let nc = MyNavigationController(rootViewController: tvc)
        sender.present(nc, animated: true, completion: {
            completion(true)
        })
    }


let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tvc = storyboard.instantiateViewController(withIdentifier: "TVC") as! MyTableViewController
segueToTable(self, tvc: tvc, completion: { done in
      print("segue complete")
})

      

Now, when you press the same button to go to your Facebook profile (or the Twitter button, basically anything that makes the app go to the background), this warning happens (no keyboard is shown on screen at this point):

Unable to view snapshot (>) with afterScreenUpdates: NO because the view is not in the window. Use afterScreenUpdates: YES.

Going back to the app and pressing the button again makes this warning appear (and every attempt thereafter):

A snapshot snapshot that has not been displayed results in blank snapshots. Make sure your view has been viewed at least once before the snapshot or snapshot after screen updates.

I understand this has to do with the view snapshot which happens automatically before entering the background. For some reason he doesn't like to do this in a view that was presented modally. I've tried various things based on other posts, but can't seem to get the warnings to go away.

Any help is appreciated.

+3


source to share





All Articles