2016-04-14 107 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参数中的“用户交互” –

相关问题