views:

140

answers:

2

My app pulls up a uitableview screen when the user clicks a settings button. I can't figure out how to wire up the request to dismiss with the action.

How do I dismiss this view from within the uitableview?

Setting up view:

SettingsController *rootViewController = [[SettingsController alloc]
  initWithStyle:UITableViewStyleGrouped];
UINavigationController *navigationController = [[UINavigationController alloc] 
  initWithRootViewController:rootViewController];
settingsView = navigationController.view;
settingsView.frame = 
  CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view insertSubview:settingsView atIndex:0];

Bringing view to front:

- (IBAction)settingsPressed:(id)sender{
[self.view bringSubviewToFront:settingsView];
}

Placing view in back:

- (void)QuitSettings {
[self.view sendSubviewToBack:settingsView];
}

Catching "return" button click in SettingsController:

- (void) action:(id) sender{
//[super.view sendSubviewToBack:holdingView]; 
// access error [self release];
// nothing [holdingView removeFromSuperview];
// access error [super QuitSettings];
 }
A: 

Doesn't this work?

[settingsView removeFromSuperView]
Philippe Leybaert
I think it works ok, but where can I call it from?
BankStrong
+4  A: 

I sounds like you want to be using a Modal view rather than inserting a subview at a particular index.

You should use

[self presentModalViewController:myTableViewController animated:YES];

where self is the view controller that will be making the call to bring up the table view.

Then you can attach a button or action somewhere on the table view controller that will call

[self.parentViewController dismissModalViewControllerAnimated:YES];

to dismiss the table view controller.

Jasarien
Smooth. You handled my immediate question and the unstated one (how do I get rid of the hack I'm using to bring up the uitableview?).
BankStrong
how do I catch the myTableViewController wasDismissed event?
BankStrong
look at viewWillDisappear and viewDidDisappear.
Greg Martin
I think viewWillDisappear works at the myTableViewController level. I'm hoping to catch this from the top level (that called myTableViewController).
BankStrong