【发布时间】:2014-12-16 16:55:52
【问题描述】:
我有 UIviewController 包含一个 UITableView ,这是一个非常简单的代码,我只想滑动一个单元格并显示更多内容并删除和处理这两个事件,这是我非常简单的类
class ViewController: UIViewController , UITableViewDataSource , UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
let deleteClosure = { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
println("Delete closure called")
}
let moreClosure = { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
println("More closure called")
}
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let identifier = "Cell"
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]?
{
var moreAction = UITableViewRowAction(style: .Default , title: "More") { (action : UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
println("more")
}
moreAction.backgroundColor = UIColor.lightGrayColor()
var deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action: UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
println("delete")
}
return [moreAction , deleteAction]
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
{
if (editingStyle == .Delete)
{
println("delete1")
}
if(editingStyle == .Insert)
{
println("insert")
}
}
editActionsForRowAtIndexPath 函数被调用,但没有 RowActions 出现! 有什么问题 ? ,
【问题讨论】:
标签: uitableview ios8 delete-row swipe-gesture