Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.22 KB | None | 0 0
  1. //
  2. //  ViewController.swift
  3. //  SO
  4. //
  5. //  Created by Len on 7/24/17.
  6. //  Copyright © 2017 24coms. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UITableViewController {
  12.  
  13.     override func viewDidLoad() {
  14.         super.viewDidLoad()
  15.         // Do any additional setup after loading the view, typically from a nib.
  16.     }
  17.  
  18.     override func didReceiveMemoryWarning() {
  19.         super.didReceiveMemoryWarning()
  20.         // Dispose of any resources that can be recreated.
  21.     }
  22.  
  23.     override func numberOfSections(in tableView: UITableView) -> Int {
  24.         return 2
  25.     }
  26.    
  27.     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  28.         return 10
  29.     }
  30.    
  31.     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  32.         let cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
  33.         cell.textLabel?.text = "hi"
  34.         return cell
  35.     }
  36.    
  37.     override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
  38.        
  39.         let onay = UITableViewRowAction(style: .normal, title: "Onay") { action, index in
  40.             // these are my functions. but they don't work here.
  41.             self.getOnay(id: 1, status: "ok")
  42.             self.loadOnaylar(userID: 22, code: 11)
  43.         }
  44.         onay.backgroundColor = .green
  45.        
  46.         let ret = UITableViewRowAction(style: .normal, title: "Ret") { action, index in
  47.             self.getOnay(id: 1, status: "cancel")
  48.             self.loadOnaylar(userID: 22, code: 33)
  49.         }
  50.         ret.backgroundColor = .red
  51.        
  52.         return [ret, onay]
  53.     }
  54.    
  55.     override func tableView (_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
  56.         return true
  57.     }
  58.     override func tableView (_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  59.         print("editingStyle >> \(editingStyle)")
  60.     }
  61.    
  62.     func getOnay(id:Int, status:String) {
  63.         print("getOnay >> \(id), \(status)")
  64.     }
  65.    
  66.     func loadOnaylar(userID:Int, code:Int) {
  67.         print("loadOnaylar >> \(userID), \(code)")
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement