title: how to remove subviews from scrollview?
body: <p>how do i remove all subviews from my scrollview...</p>
  
  <p>i have a uiview and a button above it in the scrollview something like this....</p>
  
  <p>here is my code to add subview in scroll view</p>
  
  <pre><code>-(void)AddOneButton:(NSInteger)myButtonTag {
  lastButtonNumber = lastButtonNumber + 1;
  
  if ((lastButtonNumber == 1) || ((lastButtonNumber%2) == 1)) {
  btnLeft = 8;}
  else if ((lastButtonNumber == 2) || ((lastButtonNumber%2) == 0)) {
  btnLeft = 162;
  }
  CGRect frame1 = CGRectMake(btnLeft, btnTop, 150, 150);
  CGRect frame2 = CGRectMake(btnLeft, btnTop, 150, 150);
  UIButton *Button = [UIButton buttonWithType:UIButtonTypeCustom];
  Button.frame = frame1;
  Button.tag = myButtonTag;
  [Button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  [Button setBackgroundColor:[UIColor clearColor]];
  [Button setBackgroundImage:[UIImage imageNamed:@"WaitScreen.png"] forState:UIControlStateHighlighted];
  
      GraphThumbViewControllerobj = [[GraphThumbViewController alloc] initWithPageNumber:[[GraphIdArray objectAtIndex:myButtonTag]intValue]];
      GraphThumbViewControllerobj.view.frame=frame2;
      GraphThumbViewControllerobj.lblCounter.text=[NSString stringWithFormat:@"%d of %d",myButtonTag+1,flashCardsId.count];
      GraphThumbViewControllerobj.lblQuestion.text=[flashCardText objectAtIndex:myButtonTag];
      [myScrollView addSubview:GraphThumbViewControllerobj.view];
  
  
  [myScrollView addSubview:Button];
  
  
  if ((lastButtonNumber == 2) || ((lastButtonNumber%2) == 0)) {
  btnTop = btnTop + 162;
  }
  if (btnTop+150 &gt; myScrollView.frame.size.height) {
  myScrollView.contentSize = CGSizeMake((myScrollView.frame.size.width), (btnTop+160));}
  }
  </code></pre>
  
  <p>and here is the code to remove subviews</p>
  
  <pre><code>if(myScrollView!=nil)
  {
          while ([myScrollView.subviews count] &gt; 0) {
              //NSLog(@"subviews Count=%d",[[myScrollView subviews]count]);
              [[[myScrollView subviews] objectAtIndex:0] removeFromSuperview];
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/liHEd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/liHEd.png" alt="alt text"></a>
  </p>