Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  2. let cell = tableView.dequeueReusableCellWithIdentifier("dbColumns", forIndexPath: indexPath) as! CustomColumnTableViewCell
  3.  
  4. let column = columns[indexPath.row]
  5. cell.dbColumnName.text = column.name
  6. cell.dbColumnOrder.titleLabel?.text = column.order
  7. cell.dbColumnOrder.tag = indexPath.row
  8.  
  9. print(columns)
  10. cell.dbColumnOrder.addTarget(self, action: #selector(ViewController.showAlert(_:)), forControlEvents: UIControlEvents.TouchUpInside)
  11. return cell
  12. }
  13.  
  14. //MARK:Show Alert
  15. func showAlert(sender:UIButton){
  16. let alert = UIAlertController(title: "Column Order", message: "Please select column order", preferredStyle: .ActionSheet)
  17. let index = sender.tag
  18. let indexPath = NSIndexPath(forRow: index, inSection: 0)
  19.  
  20. alert.addAction(UIAlertAction(title: "None", style: .Default, handler: { (action) in
  21. //execute some code when this option is selected
  22. self.columns[index].order = "None"
  23. self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
  24. }))
  25.  
  26. alert.addAction(UIAlertAction(title: "Assending", style: .Default, handler: { (action) in
  27. //execute some code when this option is selected
  28. self.columns[index].order = "Assending"
  29. self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
  30. }))
  31.  
  32. alert.addAction(UIAlertAction(title: "Desending", style: .Default, handler: { (action) in
  33. //execute some code when this option is selected
  34. self.columns[index].order = "Desending"
  35. self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
  36. }))
  37.  
  38. self.presentViewController(alert, animated: true, completion: nil)
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement