How to implement Search in Parse TableViewController

时间:2015-12-08 19:28:23

标签: ios swift uitableview parse-platform uisearchbar

How to implement Search with UISearchBar in Parse's PFQueryTableViewController,So user can search though tableview Text content.

So here is my problem so far : No result in the search bar and no crash !

Everything works well but after tapping search button adding text no result!

What seems to be the problem?

There aren't many tutorial about how to make it?

I've tried and this is my code.

ViewController

animationBackgroundDots

///UPDATE UISearchBar Code.

Class PFQueryTableViewController,UISearchBarDelegate


    override func queryForTable() -> PFQuery {
        var query = PFQuery(className: "Event")

       if searchBar.text != "" {
            query.whereKey("searchText", containsString: searchBar.text!.lowercaseString)
        }
        query.cachePolicy = PFCachePolicy.CacheThenNetwork
        query.orderByAscending("createdAt")
        return query  
    }

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

        var cell = tableView.dequeueReusableCellWithIdentifier("EventCell") as! EventTableCell!
        if cell == nil {
            cell = EventTableCell(style: UITableViewCellStyle.Default, reuseIdentifier: "EventCell")
        }

        if let eventTitle = object!["eventTitle"] as? String {
                cell?.titleLabel?.text = eventTitle
        }
    }

0 个答案:

没有答案