title: UIView or UIScrollView doesn't refresh the display on programmatically created controls
body: <p>I'm creating melodramatically some controls, and they don't appear, it needs some kind of a refresh method..
  here's my layout:<br>
  <img src="https://i.stack.imgur.com/AJrcF.jpg" alt="enter image description here"></p>
  
  <p>it's a chat, and all those messages I'm creating them dynamically as the event appears, 
  what I'm creating at startup, it does appear, but what I'm creating afterward fails to show, even if the code is ok,  </p>
  
  <p>here's how am I creating the controls (by calling the following function):</p>
  
  <pre><code>- (void) AddNewMessage: (NSString *)msg date1:(NSString* ) date2  {
  
      NSString *backimage =[NSString stringWithString:@""];
      NSString *who =[NSString stringWithString:@"1"];
  
      calculatedHeight=floor( msg.length / 40 )*20;
          if (calculatedHeight&lt;30) calculatedHeight=30;
      if ([who isEqualToString:@"1"]) { 
          left=85;
          left_hour_button=25;
          backimage=@"green_bubble.png";
      }
      else {
          left=5;
          left_hour_button=240;
          backimage=@"grey_bubble.png";
      }
  
      UIButton *button1 = [[UIButton alloc] initWithFrame:CGRectMake(left, lastcalculatedHeight-10, 230, calculatedHeight+10)];   
      [button1 setBackgroundImage:[[UIImage imageNamed:backimage] stretchableImageWithLeftCapWidth:9 topCapHeight:13] forState:UIControlStateDisabled];
      [button1 setEnabled:FALSE];          
      [scrollView addSubview:button1];
      [button1 release];
  
      UIButton *buttonTime = [[UIButton alloc] initWithFrame:CGRectMake(left, lastcalculatedHeight+40, 50, 20)];  
      [buttonTime setBackgroundImage:[[UIImage imageNamed:@"hour_bubble.png"] stretchableImageWithLeftCapWidth:9 topCapHeight:13] forState:UIControlStateDisabled];
      [buttonTime setFrame:CGRectMake(left_hour_button, lastcalculatedHeight+calculatedHeight-30, 55, 25)];
      [buttonTime setTitle:date2 forState:UIControlStateDisabled];                
      [buttonTime setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled];
      buttonTime.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:8.0]; 
      buttonTime.titleLabel.lineBreakMode= UILineBreakModeWordWrap;
      [buttonTime setEnabled:FALSE];
      [scrollView addSubview:buttonTime];
      [buttonTime release];
  
  
      UILabel *labelMessage = [[UILabel alloc] initWithFrame:CGRectMake(left+5, lastcalculatedHeight-5, 220, calculatedHeight)];           
      [labelMessage setText:msg];
      [labelMessage setFont:[UIFont fontWithName:@"Arial" size:12.0]];
      [labelMessage setLineBreakMode:UILineBreakModeWordWrap];
      [labelMessage setTextColor:[UIColor blackColor]];
      [labelMessage setAdjustsFontSizeToFitWidth:NO];
      [labelMessage setNumberOfLines:floor( msg.length / 40 )+2];
      [labelMessage setBackgroundColor:[UIColor clearColor]];
      [scrollView addSubview:labelMessage];
      [labelMessage release];
  
      lastcalculatedHeight+=calculatedHeight+20;
  
      totalHeight+=calculatedHeight;  
  
      scrollView.contentSize = CGSizeMake(240, lastcalculatedHeight);
  }
  </code></pre>
  
  <p>How do I "refresh" the display?</p>
  
  <p>The scrollView is an object inside the Uiview from which the class derives</p>
  
  <p>Also I will want to scroll down to the bottom the scrollview, each time I'm adding a new message.</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/952412/uiscrollview-scroll-to-bottom-programmatically">this post</a> but either it doesn't work, or it acts weird on the simulator...
  haven't tried it on a device because I don't own an iPhone yet.</p>
  
  <p>it scrolls too much or at all, but if I go to another tab, then switch back, the scroll is scrolled at the bottom, and it even shows the controls I've created programmatically...
  Weird isn't it?</p>