ios - A custom view in between table view cells -
i wish display custom view in between table view if particular cell's attribute matches condition. this
row 1
row 2
row (n) (matches condition)
--------------------------- (custom view)
row (n+1)
row (n+2)
i using tableview , tableviewdelegate in viewcontroller
you need tabledatasource delegate. return cell class, depending on condition of object in source array in tableview cellforrowatindexpath: method of table delegate.
-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ myobjectclass * objectfromarray = [sourcearray.objectatindex: indexpath.row]; if(condition on myobjectclass or index row){ static nsstring *myidentifier = @"myreuseidentifier"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:myidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:myidentifier]; } return cell; } }else{ static nsstring *myotheridentifier = @"myotherreuseidentifier"; newuitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:myidentifier]; if (cell == nil) { cell = [[newuitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:myotheridentifier]; } return cell; } } }
Comments
Post a Comment