Question

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];
 }
Was it helpful?

Solution

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.

OTHER TIPS

Doesn't this work?

[settingsView removeFromSuperView]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top