所以....我有一個視圖控制器,當我按下一個按鈕,另一個視圖控制器出現:dismissViewControllerAnimated不dissmissing的ViewController
- (IBAction)searchButtonPressed:(id)sender {
[self presentViewController:self.controllerSearch animated:YES completion:nil];
}
內部視圖控制器號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);
}
現在我使用LazyPDFKit並談到與此委託方法:
- (void)dismissLazyPDFViewController:(LazyPDFViewController *)viewController
{
// dismiss the modal view controller
[self dismissViewControllerAnimated:YES completion:NULL];
}
我把一個斷點,我可以看到我的代碼進入委託方法,但LazyPDFViewController不會消失。
我曾嘗試以下:
[[[self presentingViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
,但把我帶回到了幾個視圖控制器遠。
我錯過了什麼嗎?
在我的第一個視圖控制器的.h
@property (strong, nonatomic) UISearchController *controllerSearch;
和.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;
}
通過什麼手段你要去LazyPDFViewController。您是否將視圖控制器推向當前視圖控制器,還是您正在呈現視圖控制器? – Arun
我認爲dismissViewController只會在您呈現ViewController時才起作用。如果你是推視圖控制器,那麼你需要彈出 – Arun
我相信我推視圖控制器,並推動LazyPDFViewController第二個視圖控制器 – user979331