title: UIScrollView - content goes out bound when scrolling
body: <p>I design the scrollview in interface builder like this</p>
  
  <p><img src="https://i.stack.imgur.com/WhE2K.jpg" alt="enter image description here"></p>
  
  <p>It looks good here. But unfortunately when I run it on emulator or device</p>
  
  <p>it becomes</p>
  
  <p><img src="https://i.stack.imgur.com/B0cOr.jpg" alt="enter image description here"></p>
  
  <p>The content in scrollview is expand outside scrollview itself and even though outside UIView that contains this scrollView.</p>
  
  <p>In my viewDidLoad (panel is the container of scrollView )</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      CGFloat adjustPanelHeight = [PTTScreenScaleUtil getAdjustHeight:self.panel.frame.size.height];
      CGRect panelRect = self.panel.frame;
      panelRect.size.height = adjustPanelHeight;
      self.panel.frame = panelRect;
  
      UIImage *image = [UIImage imageNamed:@"panel-background"];
      UIGraphicsBeginImageContext(self.panel.frame.size);
      [image drawInRect:CGRectMake(0, 0, self.panel.frame.size.width, adjustPanelHeight)];
      UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
      [self.panel setBackgroundColor:[UIColor colorWithPatternImage:newImage]];
  
      NSLog(@"scrollView Height : %f", self.scrollView.frame.size.height);
      NSLog(@"scrollView contentSize Height : %f", self.scrollView.contentSize.height);
  //    CGRect scrollViewRect = self.scrollView.frame;
  //    CGRect scrollViewContentRect = self.scrollView.frame;
  //    NSLog(@"ScrollView Height Before : %f , After : %f", self.scrollView.frame.size.height, [PTTScreenScaleUtil getAdjustHeight:self.scrollView.frame.size.height]);
  //    scrollViewRect.size.width = 280;
  //    scrollViewRect.size.height = [PTTScreenScaleUtil getAdjustHeight:270];
  //    self.scrollView.frame = scrollViewRect;
  //    [self.detailsLabel sizeToFit];
      UIView *view = [[self.scrollView subviews] objectAtIndex:0];
  //    [view sizeToFit];
  //    [self.scrollView setContentMode:UIViewContentModeScaleAspectFit];
  //    NSLog(@"ContentSize Height : %f", view.frame.size.height);
  //    scrollViewContentRect.size.height = view.frame.size.height;
      NSLog(@"Bounds : %f", view.bounds.size.height);
      self.scrollView.frame = CGRectMake(10, 10, 280, 270);
      self.scrollView.contentSize = CGSizeMake(280, 500);
      NSLog(@"Frame Height %f", self.scrollView.frame.size.height);
      //[self.scrollView setContentSize: CGSizeMake(280, 1000)];
  
      CGRect termBtnRect = self.termBtn.frame;
      CGRect mailBtnRect = self.mailBtn.frame;
      CGRect twitterBtnRect = self.twitterBtn.frame;
      CGRect fbBtnRect = self.fbBtn.frame;
      termBtnRect.origin.y = adjustPanelHeight - 10 - termBtnRect.size.height;
      mailBtnRect.origin.y = adjustPanelHeight - 10 - termBtnRect.size.height;
      twitterBtnRect.origin.y = adjustPanelHeight - 10 - termBtnRect.size.height;
      fbBtnRect.origin.y = adjustPanelHeight - 10 - termBtnRect.size.height;
      self.termBtn.frame = termBtnRect;
      self.mailBtn.frame = mailBtnRect;
      self.twitterBtn.frame = twitterBtnRect;
      self.fbBtn.frame = fbBtnRect;
  }
  </code></pre>
  
  <p>All the log return 270.0</p>
  
  <p>PS. the scroll bar is correct even though the content goes outside but the scroll bar is working correctly (stay in the scrollview's frame as arrange in interface builder)
  I have no idea how can I solve this.
  Anyone help me please.</p>
  
  <p>Thanks you.</p>