-1

I have a modal ViewController acting as a custom alert in my app.

In it, I have a UIButton title set to some "default text" in Interface Builder.

In my viewWillAppear method, I am setting the button title to "new text".

When I run the app and alert VC appears, I can visibly see the transition of UIButton from "default text" to "new text".

I thought all processing in viewWillAppear() was supposed to be invisible. Any thoughts? (I do not want to make these changes in ViewDidLoad.)

mugx
  • 9,869
  • 3
  • 43
  • 55
Kashif
  • 4,642
  • 7
  • 44
  • 97

1 Answers1

1

What you can do is create an instance of the class of the viewcontroller (Modal) and set the value of a variable that saves the title and launch that new instance. and in the didload do the assignment

class ViewControllerOne : UIViewController{
    if let modalVC = self.storyboard?.instantiateViewController(withIdentifier: "modal") as? MYViewController {
        modalVC.titleLbl.text = "New title"    
        self.present(modalVC, animated: true, completion: nil)
    }

}

class MYViewController : UIViewController{      
    @IBOutlet weak var titleLbl: UILabel!
    ...
}

Sorry my english is not very good

Samack77
  • 66
  • 1
  • 4