2013-01-02 33 views
2
UIDocumentInteractionController *documentController; 

-(void)openDocumentIn 

{ 

    NSString *filepath = [[NSBundle mainBundle]pathForResource:@"Learn Book" ofType:@"pdf"]; 
    NSLog(@"path:%@", filepath); 
    if(filepath == nil) 
    { 
     NSLog(@"filepath is nil."); 
     return ; 
    } 
    documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filepath]]; 
    documentController.delegate = self; 
    documentController.UTI = @"com.adobe.pdf"; 
    CGRect navRect = self.navigationController.navigationBar.frame; 
    navRect.size = CGSizeMake(1500.0f, 40.0f); 
    [documentController presentOpenInMenuFromRect:navRect inView:self.view animated:YES ]; 
    //[documentController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES ]; 
} 

我已经将它从“CGRectZero”更改为“navRect”,但运行后没有看到差异。为什么?presentOpenInMenuFromRect的第一个参数是什么意思?

回答

0

"presentOpenInMenuFromRect"的第一个参数是锚定菜单的位置(在坐标系统视图)。

做“CGRectZero”将无法正常工作,因为这意味着您要求一个零高度为&宽度的矩形。做整个导航栏(就像你在“navRect”上做的那样)也不会起作用。

最好只设置矩形出现在触发UIDocumentInteractionController的按钮下方或旁边。

+0

恰恰相反,'CGRectZero'通常工作正常 –

相关问题