title: Problem with removing a subview and then adding it again
body: <p>I have a problem with removing a subview, or more precisely with checking if it is still there after having deleted it.</p>
  
  <p>My app first adds a subview to self.view.</p>
  
  <pre><code>[self.view addSubview:tabsClippedView];
  </code></pre>
  
  <p>Then it adds another subview to this subview (to which it adds several buttons as subviews, but I guess this is unimportant in this context):</p>
  
  <pre><code>[tabsClippedView addSubview:tabsView];
  </code></pre>
  
  <p>Finally, I have a method which allows the tabsView to be deleted and then created again. I need to do this so as to update the number of buttons in that tabsView (as the user can delete buttons). The method looks basically like this:</p>
  
  <pre><code>[self.tabsView removeFromSuperview];
  </code></pre>
  
  <p>After that I call a method called showTabs (which I already called in the very beginning of the app in order to add the subViews). This is where it all becomes problematic and where my app crashes (I get no error in the debug console, so I don't really know what the issue is...):</p>
  
  <pre><code>    if ([tabsClippedView isDescendantOfView:self.view]) {
      NSLog(@"There is already a tabsClippedView.");
  } else {
      NSLog(@"There is no tabsClippedView. I'll add one...");
      [self initTabsClippedView];
  }
  </code></pre>
  
  <p><strong>This is where the app crashes: when trying to assess if tabsView isDescendantOfView (I don't get any of the following logs):</strong></p>
  
  <pre><code>if ([tabsView isDescendantOfView:tabsClippedView]) {
      NSLog(@"There is already a tabsView");
  } else {
      NSLog(@"There is no tabsView for the buttons. I'll add one including buttons.");
      [self initTabs];
  }
  </code></pre>
  
  <p>I'd be grateful for any suggestions where the problem could be.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>These are the methods to set up my views:</p>
  
  <pre><code>-(void) initTabsClippedView { // sets up tabsClippedView
  
  NSLog(@"initTabsClippedView method started...");
  
  CGRect tabsClippedFrame = CGRectMake(258,30,70,81*6);
  tabsClippedView = [[[UIView alloc] initWithFrame:tabsClippedFrame] autorelease];
  tabsClippedView.clipsToBounds = true;
  
  [self.view addSubview:tabsClippedView];
  
  NSLog(@"initTabsClippedView method ended.");
  </code></pre>
  
  <p>}</p>
  
  <pre><code>    -(void) initTabs {          
  
      NSLog(@"initTabs started. Adding buttons to tabsClippedView...");
  
      CGRect tabsFrame = CGRectMake(-30,0,50,480);
      tabsView = [[[UIView alloc] initWithFrame:tabsFrame] autorelease];
      [tabsClippedView addSubview:tabsView];  
  // sets up buttons in tabsClippedView
  </code></pre>
  
  <p>And this is where I delete the tabsClippedView (triggered by a button found in tabsClippedView):</p>
  
  <pre><code> -(void)tabDelete:(id)sender
  {
      UIButton *button = (UIButton *)sender;
  
      [UIView animateWithDuration:0.75
                            delay:0
                          options:UIViewAnimationOptionCurveEaseIn
                       animations:^{
  
                                      button.transform = CGAffineTransformMakeTranslation(-30, 0);                 
  
                       }
                       completion:^(BOOL finished){
  
  
                           [UIView animateWithDuration:0
                                                 delay:0
                                               options:UIViewAnimationOptionCurveEaseIn
                                            animations:^{
  
                                                [self.tabsView removeFromSuperview];
  
                                                //...                                           
                                            }
                                            completion:^(BOOL finished){
  
                                                NSLog(@"tabsView removed from Superview. Objects Deleted.");
                                                [self showTabs]; 
                                                NSLog(@"TabDelete finished. Button removed and tabsView updated accordingly.");
  
                                            }
                            ];    
                       }];
  </code></pre>
  
  <p>And this is the showTabs method which was already called when I started the app:</p>
  
  <p>-(void)showTabs {</p>
  
  <pre><code>NSLog(@"showTabs started...");
  
  currentView = @"Tabs";
  
  if ([tabsClippedView isDescendantOfView:self.view]) {
      NSLog(@"There is already a tabsClippedView.");
  } else {
      NSLog(@"There is no tabsClippedView. I'll add one...");
      [self initTabsClippedView];
  }
  
  if ([tabsView isDescendantOfView:tabsClippedView]) {
      NSLog(@"There is already a tabsView");
  } else {
      NSLog(@"There is no tabsView for the buttons. I'll add one including buttons.");
      [self initTabs];
  }
  </code></pre>