如果在mainVC中点击自定义UITableViewCell时应用程序可以正常工作,我可以在inputTableVC中编辑CoreData。现在我正试着做同样的事情,但是当UITableViewRowAction“编辑”按钮被点击时。"Delete“功能已经起作用了。
有没有办法在UITableViewRowAction中实现prepereForSegue或fetchRequest?
提前谢谢。
// Mark- My current working Segue code
override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "EditRaptor" {
let customMainVCTableCell = sender as! CustomMainVCTableCell
let indexPath = tableView.indexPathForCell(customMainVCTableCell)
let addRaptorVC:AddRaptorVC = segue.destinationViewController as! AddRaptorVC
let addRaptor:AddRaptorCoreData = fetchedResultController.objectAtIndexPath(indexPath!) as! AddRaptorCoreData
addRaptorVC.addRaptor = addRaptor
}
}
// Mark- The TableViewRowAction that needs to be fixed
public func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let managedObject:NSManagedObject = fetchedResultController.objectAtIndexPath(indexPath) as! NSManagedObject
var deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete" , handler: {
(action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
self.managedObjectContext?.deleteObject(managedObject)
self.managedObjectContext?.save(nil)
})
var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Edit" , handler: {
(action:UITableViewRowAction!, indexPath:NSIndexPath!) in
})
return [deleteAction,editAction]
}发布于 2015-08-10 07:04:14
我认为你需要做的就是在动作代码中调用performSegueWithIdentifier函数,然后在进入下一个viewController之前,prepareForSegue会自动被调用
https://stackoverflow.com/questions/31908991
复制相似问题