Search code examples
iosswiftparse-platformpfquerytableviewcontrolle

How to set background image for tableView in PFQueryTableViewController


This code in viewDidLoad works for adding a background image to a tableView in a generic tableViewController, however using the Parse SDK, it does not add a background image in a PFQueryTableViewController. What am I doing wrong in the PFQTVC?

peopleTableView.backgroundView = UIImageView(image: UIImage(named: "SFStreetcar"))  

Solution

  • Turns out simply placing the code inside viewWillLayoutSubViews did the trick:

     override func viewWillLayoutSubviews() {
            tableView.backgroundView = UIImageView(image: UIImage(named: "SFStreetcar"))
        }
    

    If that doesn't work though @user2792129 's solution is worth exploring as well.