滑动以编辑详细信息 Swift 和 Parse [英] Swipe To Edit Details Swift and Parse

查看:26
本文介绍了滑动以编辑详细信息 Swift 和 Parse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 RowAction 按钮时无法将数据传递到新的视图控制器以编辑字段.

I am having trouble passing data to a new view controller to edit the fields when using a RowAction button.

我可以通过下面的代码让 RowAction 按钮转到新的视图控制器:

I can get the RowAction button to go to the new view controller via the code below:

 override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]?  {

    var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: " Edit " , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in

        dispatch_async(dispatch_get_main_queue()) {
            self.performSegueWithIdentifier("EditDetails", sender: self)
        }   
    })
    return [editAction]
}

我可以使用以下代码使用正常的转场传递数据:

I can get the data to pass using a normal segue using the code below:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if (segue.identifier == "EditDetails") {
        [segue destinationViewController].
        var editView = segue.destinationViewController as! EditDetailsTableViewController

    if let indexPath = self.tableView.indexPathForSelectedRow() {
            let row = Int(indexPath.row)
            editView.currentObject = objects[row] as? PFObject
        }

    }
}

但是,我似乎无法同时进行.我希望用户能够单击编辑"按钮并填充这些字段的详细信息,他们可以对其进行编辑.

However, I cannot seem to do both at the same time. I would like a user to be able to click the Edit button and the details for those fields populate and they can edit them.

添加建议的解决方案……但是,仍然没有通过.

Adding in proposed solution...however, still getting nil passed.

var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: " Edit " , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in

       let objectToEdit = self.objects[indexPath.row] as! PFObject
            self.performSegueWithIdentifier("EditDetails", sender: objectToEdit)

推荐答案

我刚刚遇到了同样的问题.检查线程.底部是我自己的答案.

I just had the same issue. Check out the thread. At the bottom is my own answer.

与 indexPath 行连续的表行操作

只需发送indexPath,然后在prepareForSegue中使用它就可以使其工作.

Just send the indexPath, and then use it in the prepareForSegue to make it work.

这篇关于滑动以编辑详细信息 Swift 和 Parse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆