title: Set UIView's size same as the entire window's size
body: <p><strong>EDIT:</strong></p>
  
  <p>The UIWebView is first initialized in <code>FirstViewController</code> like this:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      self.webView = [[UIWebView alloc] initWithFrame:self.view.frame];
      self.webView.delegate = self;
      [self.view addSubview: self.webView];
      NSURL *url = [NSURL URLWithString:BASE_URL];
      NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
      [self.webView loadRequest:urlRequest];
  }
  </code></pre>
  
  <p>The reference to this <code>UIWebView</code> is passed on to the <code>SecondViewController</code>, and I add it as a subview like this:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:animated];
      self.webView.delegate = self;
      [self.view addSubview:self.webView];
  }
  </code></pre>
  
  <p>This attaches a UIWebView into a View Controller's view. If I call this function inside <code>viewDidAppear</code>, I get a UIWebView that fits the whole screen. However, if I call it inside <code>viewWillAppear</code>, UIWebView only takes half the whole screen's size. I tried comparing <code>viewController.view</code>'s sizes for <code>viewWillAppear</code> and <code>viewDidAppear</code> but they seemed to be the same.</p>
  
  <p>According to this very similar <a href="https://stackoverflow.com/questions/13079172/unable-to-set-frame-correctly-before-viewdidappear">post</a> it's appropriate to resize subviews in <code>viewDidLayoutSubviews</code>. So I tried the following:</p>
  
  <pre><code>- (void)viewDidLayoutSubviews {
      [super viewDidLayoutSubviews];
      self.webView.frame = self.view.bounds;
  }
  </code></pre>
  
  <p>but it still looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/GPzJk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GPzJk.png" alt="enter image description here"></a></p>