iBooks打开PDF - “弹出窗口无法从没有窗口的视图中呈现”

时间:2013-04-03 16:33:07

标签: ios objective-c ipad

我是一个Objective-C菜鸟试图在我的应用程序中打开iBooks库中的PDF文件。

我使用以下代码 - 它似乎创建了打开的对话框,但我收到一个错误 - “无法从没有窗口的视图中显示弹出窗口”。我不知道如何纠正这个......我在这里做错了什么?

- (void) showOptionsMenu
{
    NSURL *fileURL = [NSURL fileURLWithPath:@"ibooks://test.pdf"];
    docController = [self setupControllerWithURL:fileURL usingDelegate:self];
    bool didShow = [docController presentOptionsMenuFromBarButtonItem:self.toolbarItems[0] animated:YES];
    if(!didShow)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Sorry, app not found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }   
}

1 个答案:

答案 0 :(得分:0)

通过为我的UIDocumentInteractionController声明属性来解决问题。