title: Why showing and hiding view from viewWillAppear or viewDidAppear doesn't work
body: <p>I recently converted an app from modal <code>viewControllers</code> to <code>TabBarController</code> and there is some code that used to work fine before the conversion but now I'm having a hard time making it work in the TabBar app.</p>
  
  <p>What I want to do is update the <code>UI</code>in a tab based on user setting stored in <code>UserDefaults</code>, these settings happen in the <code>Settings</code> tab (ViewController) and I want to update the UI in a different tab based on the settings that were set by the user. Before the conversion the code was in the <code>ViewDidLoad</code> and it was working fine but now with <code>TabBar</code> there is no <code>ViewDidLoad</code> I'm using viewWillAppear, to update as soon as the tab is activated but isn't working.</p>
  
  <p>Here is the code...</p>
  
  <pre><code>class UserInputViewController: UIViewController{
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // customizeApp() // everything works if called from here
      }
  
      override func viewWillAppear(_ animated: Bool) {
          customizeApp() // Doesn't work
      }
      override func viewDidAppear(_ animated: Bool) {
          // customizeApp() // Doesn't work
      }
  
       func customizeApp(){
  
          if isView1(){
              view1.isHidden = false
          }else{
              view1.isHidden = true
          }
  
          if isButton1(){
              button1.isHidden = false
          }else{
              button1.isHidden = true
          }
  
          if isTextField1(){
              textField1.isHidden = false
          }else{
              textField1.isHidden = true
          }
  
          if isTextField2(){
              textField2.isHidden = false
          }else{
              textField2.isHidden = true
          }
  
          /// Adjust Screen based on settings
          if textField1.isHidden &amp;&amp; textField2.isHidden{
              constraintMainButton.constant = 7
              return
          }
          if textField1.isHidden {
              constraintMainButton.constant = 45
          }
          if textField2.isHidden {
              constraintMainButton.constant = 45
          }
      }
  
      func isView1()-&gt;Bool{// read UserDefaults}
      func isButton1()-&gt;Bool{// read UserDefaults}
      func isTextField1()-&gt;Bool{// read UserDefaults}
      func isTextField2()-&gt;Bool{// read UserDefaults}
  }
  </code></pre>
  
  <p>I also tried <code>viewDidLayoutSubviews</code> but it didn't work either.</p>
  
  <h3>Any idea what could be wrong?</h3>
  
  <p>FYI - All values come as expected from <code>UserDefaults</code>. </p>
  
  <h2>EDIT:</h2>
  
  <p>My Issue was that I was repositioning my views but I wasn't repositioning them back to their original position. I know it sounds silly but I was tricked by the fact that the exact same code was working fine when I was calling <code>customizeApp()</code> from <code>ViewDidLoad</code> before changing to <code>UITabBar</code>. I ended up calling <code>customizeApp()</code> from <code>viewDidAppear()</code> method.</p>
  
  <pre><code> class UserInputViewController: UIViewController{
  
      /// ... Code
  
      override func viewDidAppear(_ animated: Bool) {
          customizeApp()
      }
  
       func customizeApp(){
  
          /// ... Code
  
          /// Adjust Screen based on settings
          if textField1.isHidden &amp;&amp; textField2.isHidden{
              constraintMainButton.constant = 7
              return
          }
          if textField1.isHidden {
              constraintMainButton.constant = 45
              return // added
          }
          if textField2.isHidden {
              constraintMainButton.constant = 45
              return // added
          }
  
          constraintMainButton.constant = 83 // added: Original Position
      }
      /// .... Code
  }
  </code></pre>
  
  <p>Thanks</p>