首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用UITableViewRowAction执行分段控制

使用UITableViewRowAction执行分段控制
EN

Stack Overflow用户
提问于 2015-08-10 05:24:56
回答 1查看 361关注 0票数 2

如果在mainVC中点击自定义UITableViewCell时应用程序可以正常工作,我可以在inputTableVC中编辑CoreData。现在我正试着做同样的事情,但是当UITableViewRowAction“编辑”按钮被点击时。"Delete“功能已经起作用了。

有没有办法在UITableViewRowAction中实现prepereForSegue或fetchRequest?

提前谢谢。

代码语言:javascript
复制
// 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]
}
EN

回答 1

Stack Overflow用户

发布于 2015-08-10 07:04:14

我认为你需要做的就是在动作代码中调用performSegueWithIdentifier函数,然后在进入下一个viewController之前,prepareForSegue会自动被调用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31908991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档