Setting background image for PFQueryTableViewController

假如想象 提交于 2019-12-25 03:55:13

问题


Swift iOS
xcode 7.1 Beta

I am trying to set background image on the PFQueryTableViewController. I tried dragging the table from the story board (Ref. outlet: tableView) but I am not able to make the code work referring to that outlet.

    let image = UIImage(named: "Background")
    tableView.backgroundView = UIImageView(image: image)

The app crashes stating:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:.

I even tried setting the background color tableView.backgroundColor = UIColor.greenColor()

But again, the app crashes

Can someone explain what's going on in here? I searched online, but most of the posts are only related to fetching images inside the PFQueryTableViewController cell.


回答1:


Try using the same code inside the queryForTable() block that returns query. It should work. No need of reference outlet.

Code should be something like:

override func queryForTable() -> PFQuery {

  let image = UIImage(named: "YourImageName")
  tableView.backgroundView = UIImageView(image: image)

  // your PFQueryTableViewController query goes here.... 

  return query
}


来源:https://stackoverflow.com/questions/33323137/setting-background-image-for-pfquerytableviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!