ios - How do I initialize a table view in edit / re-ordering mode? -
i want table view in view re-orderable. cannot figure out. have rows in table view can't re-ordering handles show up.
for table view prototype cell, made sure there check in indentation > "shows re-order controls", didn't anything.
this how whole class looks like:
class viewcontroller: uiviewcontroller { ... @iboutlet var currenttable: uitableview! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. currenttable.editing = true } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return unitcategories.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = uitableviewcell(style: uitableviewcellstyle.default, reuseidentifier: "cell") cell.textlabel?.text = "\(unitcategories[indexpath.row])" return cell } /*func tableview(tableview: uitableview, editingstyleforrowatindexpath indexpath: nsindexpath) -> uitableviewcelleditingstyle { return uitableviewcelleditingstyle.none }*/ }
can point me in right direction?
you need implement these 2 methods in order able show reordering control,
func tableview(tableview: uitableview, moverowatindexpath sourceindexpath: nsindexpath, toindexpath destinationindexpath: nsindexpath) { } func tableview(tableview: uitableview, canmoverowatindexpath indexpath: nsindexpath) -> bool { return true }
as stated in header file,
func tableview(tableview: uitableview, canmoverowatindexpath indexpath: nsindexpath) -> bool
allows reorder accessory view optionally shown particular row. default, reorder control shown if datasource implements:
-tableview:moverowatindexpath:toindexpath: