ivanvorobei / SPLarkController

Custom transition between controllers. Settings controller for your iOS app.
https://opensource.ivanvorobei.io
MIT License
988 stars 47 forks source link

update parent controller #11

Closed miladswift closed 4 years ago

miladswift commented 4 years ago

hi sir i go the lark controller with press a button and in lark controller i type a text in text field and then i press a button and i want send my text to parent controller when i back to parent controller nothings changed whats my problem ? here is my code thanks `import UIKit import SPLarkController class ViewController: UIViewController {

@IBOutlet weak var labelResult: UILabel!
internal var  labelText = ""
@IBAction func goToLarkController(_ sender: Any) {

    let vc = storyboard?.instantiateViewController(withIdentifier: "ViewController2")
    let transitionDelegate = SPLarkTransitioningDelegate()
    vc?.transitioningDelegate = transitionDelegate
    vc?.modalPresentationStyle = .custom
    vc?.modalPresentationCapturesStatusBarAppearance = true
    self.present(vc!, animated: true, completion: nil)
}

override func viewDidLoad() {
    super.viewDidLoad()

    labelResult.text = labelText

}}`

`import UIKit import SPLarkController class ViewController2: UIViewController {

@IBOutlet weak var t: UITextField!
@IBAction func act(_ sender: UIButton) {
    let backToMainController = storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
    backToMainController.labelText = t.text!
    let transitionDelegate = SPLarkTransitioningDelegate()
    backToMainController.transitioningDelegate = transitionDelegate
    dismiss(animated: true, completion: nil)
    SPLarkController.updatePresentingController(modal: backToMainController)
}

override func viewDidLoad() {
    super.viewDidLoad()

}

}`

ivanvorobei commented 4 years ago

Please, read this section

miladswift commented 4 years ago

Please, read this section

thanks for your answer a lot but i read it and i dont know what my problem is

ivanvorobei commented 4 years ago

Ah sorry, you found this function. Which controller you pass for modal func? settings or root? try change

miladswift commented 4 years ago

Ah sorry, you found this function. Which controller you pass for modal func? settings or root? try change

first i pass root controller for modal func now i try both its not working :((((( i tried for 9 hours :(( i recall my viewdiLoad (root controller) and i figure out parameters changed but root view does not changed :(( i dont know what to do can you check my code ? i appreciate so much

ivanvorobei commented 4 years ago

in modal func you should pass settings controller (bottom)

miladswift commented 4 years ago

in modal func you should pass settings controller (bottom)

i'm sorry i'm beginner how should pass the controller that i already in ? i don't want border you but i'm in serious trouble

1 2 3

the label in main controller does't change that's my problem

ivanvorobei commented 4 years ago

@miladswift it not updated even after close controller?

miladswift commented 4 years ago

@miladswift it not updated even after close controller?

yes i run it even on my phone same issue as you see in viewDidLoad i put a print order that show us the parameter changed ("XXXXXXXX") but in root controller , text label does't changed i'm work on it about i don't know maybe 20 hours :| i even use snapshotViewAfterScreenUpdates func same issue

ivanvorobei commented 4 years ago

Dear friend, problem not with my project. You need found problem in your code.