m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
973 stars 146 forks source link

Passing data back from the PresentationController #117

Closed hat8 closed 7 years ago

hat8 commented 8 years ago

Hello,

Briefly: I have a ViewController A and a MZFormSheetPresentationController B (TableView), and I want to pass data back from B -> A. I already tried to use several methods like protocol, delegate, unwind segue etc, but it seems that there is no effect. As I am new to Swift and iOS, I'm not sure if it's because I didn't find the right method. Thank you very much for helping.

More details: On my ViewController A, there is a button which present a MZFormSheetPresentationController B, just as in the example given:

@IBAction func withWhoPop(sender: UIButton) {
    let navigationController = self.storyboard!.instantiateViewControllerWithIdentifier("Navigation") as! UINavigationController
    let formSheetController = MZFormSheetPresentationViewController(contentViewController: navigationController)
   formSheetController.presentationController?.shouldDismissOnBackgroundViewTap = true
    formSheetController.presentationController?.contentViewSize = CGSizeMake(300, 500) 
    self.presentViewController(formSheetController, animated: true, completion: nil)
}

B is a TableView, and each row corresponds to a group. Each row has: a label (name of the group), and a button (which leads to a distinct tableView C. C contains the elements of the corresponding group).

Once the used has selected a row in B, I want to pass the name of the row back to A, and replace the label of the button on A by this name.

Thank you very much for your reading time, and I would be grateful if you could give me some indication. I tried for several days and don't see what I can do now.

hat8 commented 7 years ago

Sorry, may I ask if it is closed because my question is not relevant...? Thanks

m1entus commented 7 years ago

You have to implement standard delegate, or block pattern with callback, MZFormSheetPrenestationController is only for presentation rest you have to do by yourself and there is no difference with behaviour between this and standard one. I would recomment you to ask a question on stackoverflow

hat8 commented 7 years ago

Thank you very much for your kind confirmation, I will try again.