设置PFQueryTableViewController的背景图像 [英] Setting background image for PFQueryTableViewController

查看:79
本文介绍了设置PFQueryTableViewController的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift iOS
xcode 7.1 Beta

我正在尝试在PFQueryTableViewController上设置背景图像.我尝试从故事板上拖动表格(参考插座:tableView),但无法使代码在引用该插座的情况下工作.

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:.

我什至尝试设置背景色tableView.backgroundColor = UIColor.greenColor()

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

但是同样,应用崩溃了

有人可以解释这里发生了什么吗?我在网上搜索,但大多数帖子仅与在PFQueryTableViewController单元内部获取图像有关.

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.

推荐答案

尝试在返回查询的queryForTable()块中使用相同的代码.它应该工作.无需参考插座.

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

代码应类似于:

override func queryForTable() -> PFQuery {

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

  // your PFQueryTableViewController query goes here.... 

  return query
}

这篇关于设置PFQueryTableViewController的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆