Eliminating ViewControllerAnimated deviations only works after clicking TableView Row again

In my iOS application, I present a UItableViewController using

...
[self presentViewController:vc animated:YES completion:nil];
...

Now, after I click a row in my table view, I want to reject my tableview controller:

#pragma mark UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self dismissViewControllerAnimated:true completion:^(void) {
        NSLog(@"dismissed");
    }];
}

Now my problem is: Eliminating the deviations ViewControllerAnimated works as intended, but I have to click the line 2 times. The first time you click on a line, nothing happens.

Observations so far:

  • I press the line once: nothing happens
  • I press the line 2 times: TableviewController fires, "fires" is registered
  • I click the row once and reject the Tableview, clicking somewhere outside the modality: "fired" is logged

, "", . .

- , ?

+4
4

par ShahiM : .

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSelectorOnMainThread:@selector(dismissAndshowPdf) withObject:nil waitUntilDone:NO];
}

- (void) dismissAndshowPdf {
    [self.presentingViewController dismissViewControllerAnimated:true completion:^(void) {
         NSLog(@"dismissed");
    }];
}
+6

@rmaddym, didSelectRowAtIndexPath: . [self.presentingViewController dismissViewControllerAnimated:] [self dismissViewControllerAnimated:]

+1

deselectRowAtIndexPath

0

self.definesPresentationContext = true UITableViewController

.

0

Source: https://habr.com/ru/post/1618271/


All Articles