我是一个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];
}
}
通过为我的UIDocumentInteractionController声明一个属性来解决这个问题。