ios - Swift Parse and Search Bar not giving results -
i have parsetableviewcontroller, parsetableviewcell , uisearchbar outlet on view. data comes expected when search nothing happens , crashes app. here code, there no error. think i'm missing point here.. thank you
import uikit import parseui import parse class profiltableviewcontroller: pfquerytableviewcontroller, uisearchbardelegate{ let backgroundimage = uiimage(named: "a.png") var arka: uiimageview! @iboutlet weak var searchbar: uisearchbar! override func viewdidload() { super.viewdidload() arka = uiimageview(frame: view.bounds) arka.contentmode = .scaletofill arka.clipstobounds = true arka.image = backgroundimage arka.center = view.center view.addsubview(arka) self.view.sendsubviewtoback(arka) tableview.backgroundview = arka self.addeffect() } override init(style: uitableviewstyle, classname: string!) { super.init(style: style, classname: classname) } required init(coder adecoder: nscoder) { super.init(coder: adecoder)! self.parseclassname = "profillistesi" self.textkey = "profilename" self.pulltorefreshenabled = true self.paginationenabled = false } override func queryfortable() -> pfquery { var query = pfquery(classname: "profillistesi") if searchbar.text != "" { query.wherekey("profilename", containsstring: searchbar.text!.lowercasestring) } query.cachepolicy = .cachethennetwork query.orderbyascending("profilename") query.limit = 1000 return query } func searchbartextdidendediting(searchbar: uisearchbar) { searchbar.resignfirstresponder() self.loadobjects() } func searchbarsearchbuttonclicked(searchbar: uisearchbar) { searchbar.resignfirstresponder() self.loadobjects() } func searchbarcancelbuttonclicked(searchbar: uisearchbar) { searchbar.text = "" searchbar.resignfirstresponder() self.loadobjects() } override func viewdidappear(animated: bool) { tableview.reloaddata() searchbar.delegate = self } override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath, object: pfobject?) -> profiltableviewcell { var cell = tableview.dequeuereusablecellwithidentifier("profilsegue") as! profiltableviewcell! if cell == nil { cell = profiltableviewcell(style: uitableviewcellstyle.default, reuseidentifier: "profilsegue") } if let profil = object?["profilename"] as? string { cell?.profillabel?.text = profil } if let sistem = object?["profiletype"] as? string { cell?.sistemlabel?.text = sistem } return cell } override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "detaysegue" { var detailscene = segue.destinationviewcontroller as! profildetayviewcontroller if let indexpath = self.tableview.indexpathforselectedrow { let row = int(indexpath.row) detailscene.currentobject = (objects?[row] as! pfobject) } } } func addeffect() { let effect = uiblureffect(style: uiblureffectstyle.dark) let effectview = uivisualeffectview(effect: effect) effectview.frame = cgrectmake(0, 0, self.view.frame.width, self.view.frame.height) arka.addsubview(effectview) arka.layer.cornerradius = 0 arka.layer.maskstobounds = true; } }
Comments
Post a Comment