user1248568
user1248568

Reputation: 621

Dismiss ViewController + Table ViewController + Master-Detail app

I have a Master-Detail application. Both master and detail are UITableViewControllers. In detail scene I created a button and call to it action

- (IBAction)completeTaskButtonPressed:(id)sender {
    [[self delegate] removeCompletedTask:self.indexFromRow controller:self];
}

In Master VC implementation I have method

- (void) removeCompletedTask:(NSInteger)index controller:(DetailViewController *) controller {
    [self.dataController.masterTasksList removeObjectAtIndex:index];
    [self.tableView reloadData];
    [self dismissViewControllerAnimated:YES completion:NULL];
}

These method must delete selected row and go back to the Master View. The problem is that it removes the row but DONT dismiss detail view. Any help will be usefull.

Upvotes: 3

Views: 1862

Answers (2)

MCKapur
MCKapur

Reputation: 9157

try [self dismissModalViewControllerAnimated:YES]; or you could try:

  [self.navigationController popViewControllerAnimated:YES].

You are popping the view controller which is the opposite of pushViewController:

Upvotes: 1

rickster
rickster

Reputation: 126167

Sounds like your master-detail setup involves a navigation controller. If you want to dismiss the detail view in the same manner as would tapping the Back button, use [self.navigationController popViewControllerAnimated:YES].

Upvotes: 2

Related Questions