0

var cellStatus = object["active"] as! Bool如果从中检索到的条件是,我正在尝试删除一行false。我尝试了几种不同的方法,但似乎无法正常工作。隐藏单元格只会在 tableView 中留下很大的空白。

class TableViewController: PFQueryTableViewController {

    override init(style: UITableViewStyle, className: String!) {
        super.init(style: style, className: className)
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.parseClassName = "specials"
        self.pullToRefreshEnabled = true
    }

    // Define the query that will provide the data for the table view
    override func queryForTable() -> PFQuery {
        var query = PFQuery(className: parseClassName!)
        query.limit = 6
        query.orderByAscending("specialRank")
        return query
    }

    //override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFTableViewCell {

        var cellStatus = object["active"] as! Bool

        var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! PFTableViewCell!

        if cell == nil {
            cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
        }

        if let locationName = object["locName"] as? String {
            cell?.textLabel?.text = locationName
        }
        if let spec = object["special"] as? String {
            cell?.detailTextLabel?.text = spec
        }

        return cell
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        // Get the new view controller using [segue destinationViewController].
        var detailScene = segue.destinationViewController as! DrinkInfoViewController

        // Pass the selected object to the destination view controller.
        if let indexPath = self.tableView.indexPathForSelectedRow() {
            let row = Int(indexPath.row)
            detailScene.currentObject = objects?[row] as? PFObject!
        }
    }

    override func viewWillAppear(animated: Bool)    
    {
        self.navigationController?.navigationBarHidden = false
    }
}
4

0 回答 0