// ViewController.swift
// RefresingTableviewCell
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet var tblview: UITableView!
var aa = ["1","2","3","4","5","6","7","8","9","10"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tblview.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "cell")
self.tblview.isEditing = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return aa.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell : TableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCell
cell.lbl.text = aa[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
let movedObject = self.aa[sourceIndexPath.row]
aa.remove(at: sourceIndexPath.row)
aa.insert(movedObject, at: destinationIndexPath.row)
// NSLog("%@", "\(sourceIndexPath.row) => \(destinationIndexPath.row) \(aa)")
}
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
return .none
}
func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
return false
}
}
Comments
Post a Comment