所以....我有一个视图控制器,当我按下一个按钮时,会出现另一个视图控制器:
- (IBAction)searchButtonPressed:(id)sender {
[self presentViewController:self.controllerSearch animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
内部视图控制器编号2是一个表视图,当在表中选择一行时,此代码运行:
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);
}
Run Code Online (Sandbox Code Playgroud)
现在我使用的是LazyPDFKit,它附带了这个委托方法:
- (void)dismissLazyPDFViewController:(LazyPDFViewController *)viewController
{
// dismiss the modal view controller
[self dismissViewControllerAnimated:YES completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)
我提出了一个断点,我可以看到我的代码进入了委托方法,但是LazyPDFViewController并没有消失.
我尝试过以下方法:
[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
但这让我回到了几个视图控制器.
我错过了什么吗?
我的第一个视图中的附加代码Controller .h
@property (strong, nonatomic) UISearchController *controllerSearch;
Run Code Online (Sandbox Code Playgroud)
并在第一视图控制器.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;
}
Run Code Online (Sandbox Code Playgroud)
尝试这个:
- (void)dismissLazyPDFViewController:(LazyPDFViewController *)viewController
{
// dismiss the modal view controller
[[viewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
你的代码:
[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
太过分了。
| 归档时间: |
|
| 查看次数: |
2619 次 |
| 最近记录: |