现在,我正在尝试将不同的ViewControllers连接到各种操作(编辑,添加,下载,删除),然后向左滑动并随后点击。
我可以用附件动作来做,如果它只是一个动作(现在我已经连接到编辑)。我试图连接到AddViewController但不知何故它将不再适用于附件操作。我知道只能有一个附件动作,所以我该如何开始解决这个问题呢?
答案 0 :(得分:1)
我不确定我是否理解正确。您应该只使用handler
UITableViewRowAction
块edit
按照您对按钮override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject] {
var shareAction = UITableViewRowAction(style: .Default, title: "Share") { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
if let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
if self.programmatically {
// Segue to "shareFriendsSegue through a segue
self.performSegueWithIdentifier("shareFriendsSegue", sender:self)
} else {
// Programmatically without identifier
let destination1 = SomeViewController()
destination1.dataYouWantToPass = self.someData
self.navigationController?.pushViewController(destination1, animated: true)
// Programmatically with an identifier
let destination2 = self.storyboard?.instantiateViewControllerWithIdentifier("someViewController") as! SomeViewController
destination2.dataYouWantToPass = self.someData
self.showDetailViewController(destination2, sender: self)
}
}
}
var editAction = UITableViewRowAction(style: .Default, title: "Edit") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
if let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
let testObject = self.fetchedResultsController.objectAtIndexPath(indexPath) as! NSObject
// Segue to "editSegue" through a segue
self.performSegueWithIdentifier("editSegue", sender:self)
}
}
var deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
// Delete the row from tableView
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Right)
// Delete the row from Core Data
if let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as! NSManagedObject
context.deleteObject(object)
}
var error: NSError?
if(self.managedObjectContext!.save(&error)) {
if error != nil {
println(error?.localizedDescription)
}
}
}
var fourth = UITableViewRowAction(style: .Default, title: "fourth") { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
if let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
if self.programmatically {
// Segue to "shareFriendsSegue through a segue
self.performSegueWithIdentifier("anotherSegue", sender:self)
} else {
// Programmatically without identifier
let destination1 = AnotherViewController()
destination1.dataYouWantToPass = self.someData
self.navigationController?.pushViewController(destination1, animated: true)
// Programmatically with an identifier
let destination2 = self.storyboard?.instantiateViewControllerWithIdentifier("anotherViewController") as! AnotherViewController
destination2.dataYouWantToPass = self.someData
self.showDetailViewController(destination2, sender: self)
}
}
}
shareAction.backgroundColor = UIColor.greenColor()
editAction.backgroundColor = UIColor(red: 255.0/255.0, green: 107.0/255.0, blue: 107.0/255.0, alpha: 1.0)
deleteAction.backgroundColor = UIColor(red: 85.0/255.0, green: 98.0/255.0, blue: 112.0/255.0, alpha: 1.0)
return [deleteAction, editAction, shareAction, fourth]
}
所采用的方式执行此操作。我已经使用您的代码创建了几个示例,我希望这就是您的意思:
prepareForSegue
在这些示例中,使用了3种不同的方式来更改视图:
if (property1->combining_class > property2->combining_class &&
property2->combining_class > 0) {
buffer[pos] = uc2;
buffer[pos+1] = uc1;
中传递所需的任何数据。请告诉我这是您要搜索的内容。