在详细信息视图中显示UIDocumentInteractionController

时间:2014-01-26 15:29:33

标签: uisplitviewcontroller uidocumentinteraction

在我的分割视图控制器中,我在左侧的表视图中有一个文档列表。当用户选择文档时,我想在右侧的详细信息视图中显示文档。但是,当我选择文档时,documentInteractionController占用整个屏幕。如何使其符合细节视图的大小?

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.splitViewController.delegate = self;
}

-(void)viewWillAppear:(BOOL)animated
{
    if (self.selectedUserDoc) {
        NSURL *url = [[NSBundle mainBundle] URLForResource:self.selectedUserDoc.userDocTitle withExtension:@"pdf"];
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
        [self.documentInteractionController setDelegate:self];
        [self.documentInteractionController presentPreviewAnimated:YES];
    }
}

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
    return self;
}

-(UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
    return self.view;
}

-(CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
    return self.view.frame;
}

1 个答案:

答案 0 :(得分:0)

我只是有一些问题。我正在使用UIWebView:

 -(void)showDetailDocumentWithUrl:(NSURL*)documentUrl inView:(UIView*):detailView {
   CGRect r;
   r=detailView.frame;
   r.origin.y=75;  // Change frame as required
   .... 
   UIWebView* web=[[UIWebView alloc] initWithFrame:r];
   NSURLRequest *request = [NSURLRequest requestWithURL:documentUrl];
   [web loadRequest:request];
   [detailView addSubview: web];

 }

在我的应用程序中,我不需要进一步操作作为电子邮件发送选项,但我认为如果需要,您可以轻松管理它们。