title: need an advice with orientation change iphone
body: <p>my problem might be simple to some of you but i can't find a solution. I have a method where a create my views automatically (text fields, labels and text views). It's like a registration form. The problem is that when i change the screen to landscape mode, i want to change the views width. To do that i used <code>[self.view removeFromSuperview]</code> and created the views again. The problem is that the views won't get recreated with the landscape width. I can't use IB to autosize the views at orientation change. The views are created in <code>viewDidLoad</code> and removed and recreated in <code>- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation {}</code> I don't know why they don't get recreated after being removed. If there was another solution that you could share with me i would appreciate it. </p>
  
  <p><strong>Here's how i create the views:</strong></p>
  
  <pre><code>-(void)createViews:(int)width
  {
  for(int i = 0; i &lt; numberOfTextfields; i++) {
          textfieldPadding = textfieldPadding+40;//set some space between the text fields
          labelPadding = labelPadding+40;//set some space between the labels
  
          UITextField *field = [[UITextField alloc] initWithFrame:
                                CGRectMake(10,i*textfieldHeight+textfieldPadding+firstTextfieldHeight+10,width, textfieldHeight)]; 
          field.autoresizingMask = UIViewAutoresizingFlexibleWidth;
          //field.backgroundColor= [UIColor cyanColor];
          field.placeholder = [labels objectAtIndex:i];
          field.borderStyle=UITextBorderStyleRoundedRect;
          field.returnKeyType = UIReturnKeyDone;
          [field addTarget:self action:@selector(doneButton:)
  
          forControlEvents:UIControlEventEditingDidEndOnExit];
  
          UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, i*labelHeight+firstLabelHeight+labelPadding-20, width, labelHeight)];
  
          label.text = [labels objectAtIndex:i];
          //label.backgroundColor = [UIColor brownColor];
          [scrollView addSubview:field];
          [scrollView addSubview:label];
  
          [textfields addObject:field];
          [labels addObject:label];
          [field release];
          [label release];
      }
  }
  </code></pre>
  
  <p><strong>Here's where i wanted to remove them and recreate them:</strong></p>
  
  <pre><code>- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation 
  {    
      if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) 
      {
          [self.view removeFromSuperview];
          [self createViews:landscapeWidth];
      }
      else if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
      {
          [self.view removeFromSuperview];
          [self createViews:portraitWidth];
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>