Iphone remove sub view

Posted by Sharanya on Stack Overflow See other posts from Stack Overflow or by Sharanya
Published on 2012-03-22T10:09:04Z Indexed on 2012/03/22 11:29 UTC
Read the original article Hit count: 210

I have a UINavigationController. On the right top i have a button on click of which i have to get a drop down table view. I created another UIViewController Class, with xib and added it as a subView to the current view. It should appear on 1st click and disappear on the 2nd click. This should happen for all click(open view and close view). I wrote this code but dont know where i'm going wrong. someone please help

-(void)modalTableView
{
tableView1 = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil];

for (UIView *subView in self.view.subviews)
{

    if ([subView isKindOfClass:[TableViewController class]]) 
    {

         [subView removeFromSuperview];
    }

    else 
    {
        [self.view addSubview:tableView1.view];

    }
  }

}

What am i missing here?

EDIT : TableViewController is the name of my UIViewController Class

© Stack Overflow or respective owner

Related posts about ios

Related posts about uitableview