So ... I have a view controller, and when I click the button, the following view controller appears:
- (IBAction)searchButtonPressed:(id)sender { [self presentViewController:self.controllerSearch animated:YES completion:nil]; }
Internal view controller number 2 is a table view and when a row is selected in the table in which this code is executed:
NSString *phrase = nil; // Document password (for unlocking most encrypted PDF files) NSString *filePath2 = filePath; assert(filePath2 != nil); // Path to first PDF file LazyPDFDocument *document = [LazyPDFDocument withDocumentFilePath:filePath2 password:phrase]; if (document != nil) // Must have a valid LazyPDFDocument object in order to proceed with things { LazyPDFViewController *lazyPDFViewController = [[LazyPDFViewController alloc] initWithLazyPDFDocument:document]; lazyPDFViewController.delegate = self; // Set the LazyPDFViewController delegate to self #if (DEMO_VIEW_CONTROLLER_PUSH == TRUE) [self.navigationController pushViewController:lazyPDFViewController animated:YES]; #else // present in a modal view controller lazyPDFViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; lazyPDFViewController.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:lazyPDFViewController animated:YES completion:NULL]; #endif // DEMO_VIEW_CONTROLLER_PUSH } else // Log an error so that we know that something went wrong { NSLog(@"%s [LazyPDFDocument withDocumentFilePath:'%@' password:'%@'] failed.", __FUNCTION__, filePath2, phrase); }
Now I am using LazyPDFKit and it comes with this delegate method:
- (void)dismissLazyPDFViewController:(LazyPDFViewController *)viewController {
I set a breakpoint, and I see that my code goes into the delegate method, but LazyPDFViewController does not disappear.
I tried the following:
[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
but this returns me several view controllers.
Did I miss something?
Extra code in my first view .h controller
@property (strong, nonatomic) UISearchController *controllerSearch;
and in the first view of the controller .m
- (UISearchController *)controller { if (!_controllerSearch) { // instantiate search results table view UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil]; LHFileBrowserSearch *resultsController = [storyboard instantiateViewControllerWithIdentifier:@"SearchResults"]; // create search controller _controllerSearch = [[UISearchController alloc]initWithSearchResultsController:resultsController]; _controllerSearch.searchResultsUpdater = self; // optional: set the search controller delegate _controllerSearch.delegate = self; } return _controllerSearch; }