xcode - tableView.insertRowsAtIndexPaths with prototype cell -


i'm trying insert 1 of prototype cells in tableview. defined 2 prototype cells , gave them unique identifiers couldn't manage insert them using specific identifier. there no such function tableview.insertrowsatindexpaths identifier.

any thoughts guys?

you can use cellforrowatindexpath , inside function, can deque prototype cell. here example

override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {         //you can have if condition here choose between ur prototype cells         let cell = tableview.dequeuereusablecellwithidentifier("unique id_1", forindexpath: indexpath) as! uitableviewcell           // configure cell...          return cell     } 

here more common way this

//in parent class override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "maincatselectedsegue" {         if let tvc = segue.destinationviewcontroller as? yourtableviewcontrollerclass{             tvc.model = self.model //the data wanna populate table view with. if model not current class, can ingore         }     } }  //in tableview calss override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     if indexpath.row % 2 != 0{         let cell = tableview.dequeuereusablecellwithidentifier("subincomecat", forindexpath: indexpath) as! tableviewcell //or uitableviewcell if have no custom calls cells     }     let cell = tableview.dequeuereusablecellwithidentifier(storyboard.cellreusidentifier, forindexpath: indexpath) as! tableviewcell      // configure cell...     let rowcontent = yourmodel[indexpath.section][indexpath.row]     //now fill cell content like...     //cell.textlabel?.text = rowcontent.text     //cell.detailtextlabel?.text = rowcontent.detail      return cell } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -