title: addsubview from nib file in completionHandler block after checking push notification permissions
body: <p>I want to check if a device has PushNotification permissions for my app and than to display a dialog. </p>
  
  <p>Therefore I wrote this function:</p>
  
  <pre><code>func initPushNotificationDialog() {
      let center = UNUserNotificationCenter.current()
      center.getNotificationSettings { (settings) in
          if(settings.authorizationStatus == .notDetermined) {
  
              let myView = Bundle.loadView(fromNib: "PushNotificationPermissionView", withType: PushNotificationPermissionView.self)
              myView.layer.cornerRadius = 20.0
              myView.layer.borderColor = UIColor.darkGray.cgColor
              myView.layer.borderWidth = 1.0
              myView.center = self.view.center
  
              myView.layoutIfNeeded()
  
              DispatchQueue.main.async {
                  self.view.addSubview(myView)
              }
  
  
          }
      }
  }
  </code></pre>
  
  <p>The function is called in viewDidLoad() of the view controller.</p>
  
  <p>This is how the nib file looks like:
  <a href="https://i.stack.imgur.com/mrwPi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mrwPi.png" alt="enter image description here"></a></p>
  
  <p>But the problem is, that if I run the app and there are not permissions defined, I get the PushNotificationPermissionView empty with no text inside. After a few seconds displaying empty content suddenly the view gets filled with content. </p>
  
  <p>I didn't understand why and how this behavior is happening. I tried a few things like running it in the main queue and stuff like that but nothing worked. I want that the content is getting filled directly. </p>
  
  <p>If I create the Dialog view not in completionHandler block, everything works great.</p>