PresentModalViewController в UISplitViewControllers detailView, не отображающий представление в полноэкранном режиме
Я добавил представление UISplitViewController в моем представлении mainViewControllers, код ниже.
documentsRootViewController = [[DocumentsRootViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:documentsRootViewController];
documentsRootViewController.title = @"Document List";
documentDetailView = [[DocumentsDetailView alloc] initWithNibName:@"DocumentsDetailView" bundle:nil];
documentsRootViewController.detailViewController = documentDetailView;
docSplitViewController = [[UISplitViewController alloc] init];
docSplitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, documentDetailView, nil];
docSplitViewController.delegate = documentDetailView;
CGRect splitViewFrame = CGRectMake(0, 0, cetralArea.frame.size.width, cetralArea.frame.size.height);
docSplitViewController.view.frame = splitViewFrame;
[cetralArea addSubview:docSplitViewController.view];
теперь я хочу представить ViewController из DetailView элемента UISplitViewController. Я пытаюсь сделать это, как показано ниже внутри DetailViewControllers Click Me! нажмите кнопки.
![enter image description here]()
- (IBAction) buttonClicked:(id)sender
{
NSString *phrase = nil; // Document password (for unlocking most encrypted PDF files)
NSArray *pdfs = [[NSBundle mainBundle] pathsForResourcesOfType:@"pdf" inDirectory:nil];
NSString *filePath = [pdfs lastObject]; assert(filePath != nil); // Path to last PDF file
ReaderDocument *readerDocument = [ReaderDocument withDocumentFilePath:filePath password:phrase];
if (readerDocument != nil) // Must have a valid ReaderDocument object in order to proceed with things
{
ReaderViewController *rViewController = [[ReaderViewController alloc] initWithReaderDocument:readerDocument];
rViewController.delegate = self; // Set the ReaderViewController delegate to self
[self presentModalViewController:rViewController animated:NO];
}
}
но это приводит к неудобному представлению
![enter image description here]()
может кто-нибудь предположить, в чем проблема, спасибо заранее.
Ответы
Ответ 1
В ваших скриншотах я не могу сказать, где находится ваш контроллер просмотра с левой стороны и правой стороны (подробный вид). Измените цвета фона для разных позиций. Кажется, у вас проблемы с ними.
В любом случае вы можете попробовать представить контроллер модального представления из splitView вместо Detail.
[splitViewController presentModalViewController:rViewController animated:NO];
Ответ 2
Я считаю, что трюк здесь изменяет modalPresentationStyle (и, необязательно, modalTransitionStyle) контроллера вида, который вы хотите отобразить по умолчанию:
ReaderViewController *rViewController = [[ReaderViewController alloc] initWithReaderDocument:readerDocument];
rViewController.delegate = self; // Set the ReaderViewController delegate to self
rViewController.modalPresentationStyle = UIModalPresentationFullScreen;
rViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:rViewController animated:YES completion:nil];
Ответ 3
У меня была та же проблема (в iOS 5.1). Установите modalPresentationStyle в UIModalPresentationPageSheet, и он должен работать как ожидалось.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
rViewController.modalPresentationStyle = UIModalPresentationPageSheet;
rViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
}
Ответ 4
Что я нашел, вы даете размер splitview, например cetralArea.frame.size.width
.
Вместо этого просто дайте прямо размер, который вы хотите передать Splitview.
Надеюсь, что это сработает для вас.