How can I remove the present view when I have added more than one subView ?
- by srikanth rongali
How can I remove the present view when I touched the close button.
I did [self.view removeFromSuperView] when I added only one subView. It worked. But, I have now added another subView to the previous subView. I need to to get the parent view . How can I do it. My code of adding the subView is here. When I did the following only one view is removed.
//FirstViewController: UIViewController
-(void)libraryFunction:(id)sender
{
LibraryController *libraryController = [[LibraryController alloc]init];
[self.view addSubview:libraryController.view];
}
//LibraryController: UIViewController
-(void)viewDidLoad{
RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navController = aNavigationController;
[aNavigationController release];
[rootViewController release];
[self.view addSubview:navController.view];
}
//RootViewController: UITableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
}
-(void)close:(id)sender
{
[self.view removeFromSuperview];
}
Thank You.