2

mainVC でカスタム UITableViewCell がタップされたときにアプリが動作する場合、inputTableVC で CoreData を編集できます。今、私は同じことをしようとしていますが、UITableViewRowActionの「編集」がタップされたときです。「削除」機能はすでに機能しています。

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]
}
4

1 に答える 1

0

performSegueWithIdentifier必要なのは、アクションコード内で関数を呼び出すことでありprepareForSegue、次に移動する前に自動的に呼び出されると思いますviewController

于 2015-08-09T23:04:13.990 に答える