Search code examples
swiftcore-datareloaduipopovercontroller

Reload MainViewController when PopViewController dismissed


I have a main view controller and pop up controller.Please refer screen shots.

Main view controller

POPUP view controller

Code :

             @IBAction func show(sender: AnyObject) {

    var popView = popupviewcontroller(nibName:"popview",bundle:nil)
    var popController = UIPopoverController(contentViewController: popView)

    popController.popoverContentSize = CGSize(width: 450, height: 450)
  popController.presentPopoverFromRect(sender.frame, inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Down, animated: true)
}

For the popupViewcontoller i used .xib.

When press save button data saved to core data.

Lets come to my problem, in my mainViewController i fetched data and fill them in dynamically created lables.That occurred when view load.I want to reload mainViewController when close button form popViewController pressed.

I tried within the close button my code are here, i just tried to reload the mainVc :

         var mainVC = mainviewcontroller()         
    @IBAction func close(sender: AnyObject) {
 self.dismissViewControllerAnimated(true, completion: nil)
       //mainVc.viewDidLoad()
     mainVC.reloadInputViews()
   }

Does not give output. Conclusion : I want a way to refresh view controller from another view in swift.

Thanks in advance.


Solution

  • Using UITableView only we can reload the data!,So we have to use table view custom cell textfield or Label. Now we can able to reload our custom textfield data.