Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCellWithIdentifier("dbColumns", forIndexPath: indexPath) as! CustomColumnTableViewCell
- let column = columns[indexPath.row]
- cell.dbColumnName.text = column.name
- cell.dbColumnOrder.titleLabel?.text = column.order
- cell.dbColumnOrder.tag = indexPath.row
- print(columns)
- cell.dbColumnOrder.addTarget(self, action: #selector(ViewController.showAlert(_:)), forControlEvents: UIControlEvents.TouchUpInside)
- return cell
- }
- //MARK:Show Alert
- func showAlert(sender:UIButton){
- let alert = UIAlertController(title: "Column Order", message: "Please select column order", preferredStyle: .ActionSheet)
- let index = sender.tag
- let indexPath = NSIndexPath(forRow: index, inSection: 0)
- alert.addAction(UIAlertAction(title: "None", style: .Default, handler: { (action) in
- //execute some code when this option is selected
- self.columns[index].order = "None"
- self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
- }))
- alert.addAction(UIAlertAction(title: "Assending", style: .Default, handler: { (action) in
- //execute some code when this option is selected
- self.columns[index].order = "Assending"
- self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
- }))
- alert.addAction(UIAlertAction(title: "Desending", style: .Default, handler: { (action) in
- //execute some code when this option is selected
- self.columns[index].order = "Desending"
- self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None)
- }))
- self.presentViewController(alert, animated: true, completion: nil)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement