iosios5windowcalayersubview

remove subview of uiwindow?


i want to remove a view from uiwindow,so i nslog in appdelegate method,it says window's subviews count as two NSLog(@" %d",[[self.window subviews] count]); so how can i remove that subviews from window,if i remove that subviews i have tab bar controller to be continued...

- (void) GetUserCompleted

{
    NSLog(@"   %@",[[self.window subviews] objectAtIndex:0]);   
    NSLog(@"   %@",[[self.window subviews] objectAtIndex:1]); 
}

Solution

  • You can remove the a single subview using the following code.

    [subview_Name removeFromSuperview];
    

    if you want to remove all subviews form the view then use this.

    NSArray *subViewArray = [self.window subviews];
    for (id obj in subViewArray)
    {
        [obj removeFromSuperview];
    }