我通过UITableView
连接了两个segue
。我正在执行segue
使用tableViewCell
滑动操作方法将数据从firstTableView传递到secondTableView,并使用NSUserDefaults
代码保存传递的数据。但是,每当我传递数据时,它调用segue
(我知道它应该)并推送到我的secondTableView ..我想传递数据而不会在传递数据时将我的firstTableView推送到secondTableView并且我有操作按钮来访问我的secondController直接来自mainViewController。
func tableView(_ tableView: UITableView, editActionsForRowAtIndexPath indexPath: IndexPath) -> [UITableViewRowAction]? {
let shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.normal, title: "xxxxxxxxxx") { (UITableViewRowAction, NSIndexPath) -> Void in
self.performSegue(withIdentifier: "shareSegue", sender: indexPath)
// self.dismiss(animated: true, completion: nil)
}
return shareAction
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "shareSegue") {
// initialize new view controller and cast it as your view controller
let viewController = segue.destination as! ViewController
// your new view controller should have property that will store passed value
viewController.labelcell = (sendSelectedData as String as String)
}
//// I also tried the following method with no segue but the results pretty much same....
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let secondVC = storyboard.instantiateViewControllerWithIdentifier("secondTableView")
self.presentViewController(secondVC, animated: true, completion: nil)
提前致谢!!!