2016-04-14 52 views
0

我想在我的UITableViewController中實現滑動操作,但不顯示。UITableViewController中的滑動操作沒有出現在swift中

見我的代碼:

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 
     } 

     override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 
      return true 
     } 

     override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { 
      let keep = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Profiter"){(UITableViewRowAction,NSIndexPath) -> Void in 

       print("hello") 
      } 

      return [keep] 
     } 
+0

有了這些功能通常也適用於給編輯到一個UITableView。你在使用sectionIndexTitles嗎?這可以拋棄滑動操作位置,將它移動到sectionIndexTitles的左側而不是屏幕的左側。 – HalR

回答

0

嘗試使用

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { 
    let keep = UITableViewRowAction(style: .Normal, title: "Dude") { action, index in 
     print("hello") 
    } 
    keep.backgroundColor = UIColor.redColor() 
    return [keep] 
} 
+0

謝謝!其作品 ! –

+0

其實我禁用了我的tableView參數中的「用戶交互」 –