title: xcode/iOS: Autoresize to fill a view - explicit frame size is essential?
body: <p>I would like a <code>UITextView</code> to fill its <code>superView</code>, which is a plain <code>UIView</code> inside a <code>UIViewController</code> instance.</p>
  
  <p>It seems that I cannot make the <code>UITextView</code> do this solely by using the API-specified properties of <code>autoresizingMask</code> and <code>autoresizesSubviews</code>. Setting these as shown here does nothing; the <code>UITextView</code> remains small even though its <code>superView</code> fills the screen.</p>
  
  <pre><code>// use existing instantiated view inside view controller;
  // ensure autosizing enabled
  self.view.autoresizesSubviews = YES;
  self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight|
                               UIViewAutoresizingFlexibleWidth;
  // create textview
  textView = [[[UITextView alloc] autorelease] initWithFrame:CGRectMake(0, 0, 1, 1)];
  // enable textview autoresizing
  [textView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|
                                UIViewAutoresizingFlexibleHeight];
  // add textview to view
  [self.view addSubview:textView];
  </code></pre>
  
  <p>However, if I instantiate my own view inside the view controller, replacing its '.view' property, then everything works as expected, and the textView fills its superview:</p>
  
  <pre><code>// reinstantiate view inside view controller
  self.view = [[UIView alloc]init];
  // create textview
  textView = [[[UITextView alloc] autorelease] initWithFrame:CGRectMake(0, 0, 1, 1)];
  // enable textview autoresizing
  [textView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|
                                UIViewAutoresizingFlexibleHeight];
  // add textview to view
  [self.view addSubview:textView];
  </code></pre>
  
  <p>I've tried both code chunks inside all of these initialisers/methods, and the same situation arises in every case:</p>
  
  <pre><code>-(id)init;
  -(id)initWithFrame:(CGRect)frame;
  -(void)viewDidLoad;
  </code></pre>
  
  <p>I realise that reinstantiating the '.view' of the <code>UIViewController</code> is fugly, can anyone explain what I'm doing wrong? I presumed I could overcome the issue by having initial frame-setting code in my <code>UIViewController</code> to resize the <code>UITextView</code> once, and thereafter <code>autoresizing</code> would operate as desired.</p>
  
  <pre><code>-(void)viewDidLoad {
      textView.frame = self.view.frame;
  }
  </code></pre>
  
  <p>... but seemingly the view.frame is not set up at this stage, it does not have its '.size' values defined, so once again textView remains small.</p>
  
  <p>What's the proper way of achieving what I want? Must I explicitly specify the fullscreen dimensions via <code>UITextView:initWithFrame</code> to get it to fill its superview?</p>
  
  <p>I'd be grateful for any advice you can offer.</p>