【发布时间】:2015-06-22 01:30:03
【问题描述】:
我正在使用 commitEditingStyle 进行删除。我在单元格中添加了共享按钮。现在我只是在单元格中使用共享按钮。我想在单元格中使用这两个。我应该使用像我的“分享”按钮这样的自定义删除按钮吗?我可以为此做些什么?
我的代码在这里:
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
// Delete the row from the data source
var object: PFObject = self.noteObjects.objectAtIndex(indexPath.row) as! PFObject
object.delete()
self.fetchAllObjectsFromLocalDatastore()
self.fetchAllObjects()
tableView.reloadData()
//tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
}
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]?
{
var shareAction = UITableViewRowAction(style: .Normal, title: "Share") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let object: PFObject = self.noteObjects[indexPath.row] as! PFObject
let firstActivityItem = object["title"] as! String
let secondActivityItem = object["text"] as! String
let activityViewController = UIActivityViewController(activityItems: [firstActivityItem, secondActivityItem], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
}
shareAction.backgroundColor = UIColor.blueColor()
return [shareAction]
}
【问题讨论】:
标签: ios swift uitableview xcode6