0

I have two UITableView connected through segue. I am performing segue to pass data from my firstTableView to secondTableView using tableViewCell swipe action method and saving the passed data using NSUserDefaults code works ok. But, Every time when I passed data it calls segue(I know it supposed to) and pushing to my secondTableView..I want to pass data without pushing my firstTableView to secondTableView when passing data and I have action button to access my secondController directly from 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)

Thanks in advance!!!

Joe
  • 8,868
  • 8
  • 37
  • 59
  • I am not sure if I undestand the problem correctly. You want to access your second VC by tapping a button, but the content of this VC will depend on selected tableViewCell in the first VC right? – theDC Oct 12 '16 at 10:36
  • @DCDC hi, From my code i can pass data and save etc. Let me explain in a simple way . Imagine, I have two button in my firstTableView 1st button for passing data to my secondTableView using segue and 2nd button(tabBarButton) to access my secondTableview directly. I want to pass data when 1st button pressed with out any view transition....hope you can understand.... – Joe Oct 12 '16 at 10:46
  • Take a look to these question: http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers – nbloqs Oct 12 '16 at 12:50
  • And also to this one: http://stackoverflow.com/questions/39714510/sharing-information-between-viewcontollers/39715771#39715771 – nbloqs Oct 12 '16 at 12:50

0 Answers0