11

我在 mainViewControllers 视图中添加了 UISplitViewController 视图,代码如下。

    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];

现在我想要的是从 UISplitViewController 的 DetailView 中呈现一个 ViewController 我正在尝试在 DetailViewControllers 中按以下方式进行操作 Click Me!按钮单击。

在此处输入图像描述

- (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];        
    } 
}

但这导致了尴尬的演示

在此处输入图像描述

任何人都可以提出这里的问题,提前谢谢..

4

4 回答 4

2

在您的屏幕截图中,我无法确定您的拆分视图控制器左侧和右侧(详细视图)位于何处。更改视图的背景颜色以区分位置。看来你和他们有问题。

无论如何,您可以尝试从 splitView 而不是 Detail 呈现模态视图控制器。

[splitViewController presentModalViewController:rViewController animated:NO];
于 2012-04-24T13:46:06.430 回答
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];
于 2012-04-24T14:48:44.870 回答
1

我遇到了同样的问题(在 iOS 5.1 中)。将 modalPresentationStyle 设置为 UIModalPresentationPageSheet,它应该可以按预期工作。

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    rViewController.modalPresentationStyle = UIModalPresentationPageSheet;
    rViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
}
于 2012-05-03T15:53:05.937 回答
0

我发现你给出的 splitview 大小如cetralArea.frame.size.width.

而不是简单地直接给出你想给Splitview的大小。

希望它对你有用。

于 2012-04-25T06:17:45.963 回答