Objective c UIDocumentInteractionController将无法在Ibook中打开文档

Objective c UIDocumentInteractionController将无法在Ibook中打开文档,objective-c,ios,ipad,ibooks,uidocumentinteraction,Objective C,Ios,Ipad,Ibooks,Uidocumentinteraction,问题是,成功总是给我假?我不知道是什么问题 我的代码如下: UIDocumentInteractionController *docController = [[UIDocumentInteractionController interactionControllerWithURL:currentPDFPath] retain]; if (docController) { docController.delegate = self; BOOL success = [docCo

问题是,成功总是给我假?我不知道是什么问题

我的代码如下:

UIDocumentInteractionController *docController = [[UIDocumentInteractionController interactionControllerWithURL:currentPDFPath] retain];

if (docController)
{
    docController.delegate = self;

    BOOL success = [docController presentOptionsMenuFromBarButtonItem:openInButton animated:YES]; 
    //BOOL success = [docController presentOpenInMenuFromBarButtonItem:openInButton animated:YES];
    NSLog(@"success: %d", success);
    if(!success)
    {
        UIAlertView * noApps = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your iPad doesn't seem to have any other Apps installed that can open this document (such as iBooks)" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [noApps show];
        [noApps release];

    }
}
    [docController release];
报告说:

返回值

如果显示选项菜单,则为是;如果未显示,则为否。如果菜单中没有适当的项目,则可能不会显示选项菜单

我认为您在currentPDFPath上的%3F1340297029后缀可能会阻止匹配

检查docController的UTI属性并设置为如果为零。

显示:

返回值

如果显示选项菜单,则为是;如果未显示,则为否。如果菜单中没有适当的项目,则可能不会显示选项菜单

我认为您在currentPDFPath上的%3F1340297029后缀可能会阻止匹配


检查docController的UTI属性并将其设置为如果为零。

您的崩溃问题可能是因为您的docController已被释放。您需要保留它,然后稍后自动释放它。请看这里:


您的崩溃问题可能是因为您的docController已被释放。您需要保留它,然后稍后自动释放它。请看这里:


我修改了你的代码一点,不是它是为我工作,我使用的是ARC,所以你必须改变它,以适应你的非ARC代码

BOOL success = [self.documentInteractionController presentOpenInMenuFromRect:rect inView:self.view animated:YES];

                if (success == NO) {
                    NSLog(@"No application was found");
                } else {

                    NSLog(@"Applications were found");
                }
BOOL要么返回YES,要么返回NO,如果=后面的行为TRUE,则返回YES;如果该行为FALSE,则返回NO


-David

我对您的代码做了一些修改,但它对我不起作用,我使用的是ARC,因此您必须更改它以适合您的非ARC代码

BOOL success = [self.documentInteractionController presentOpenInMenuFromRect:rect inView:self.view animated:YES];

                if (success == NO) {
                    NSLog(@"No application was found");
                } else {

                    NSLog(@"Applications were found");
                }
BOOL要么返回YES,要么返回NO,如果=后面的行为TRUE,则返回YES;如果该行为FALSE,则返回NO


-David

currentPDFPath包含哪些内容?file://localhost/var/mobile/Applications/14DD059B-9969-4960-8E24-DC586A4302D1/Library/Caches/http-_wgsn.howoco.com_media_event_117_AW12_13_Tradeshow_seasonal_analysis-_colour_1340296472.pdf%3F1340297029@PriyankaChhetri你找到解决办法了吗请告诉我,谢谢:currentPDFPath包含什么?file://localhost/var/mobile/Applications/14DD059B-9969-4960-8E24-DC586A4302D1/Library/Caches/http-_wgsn.howoco.com_media_event_117_AW12_13_Tradeshow_seasonal_analysis-_colour_1340296472.pdf%3F1340297029@PriyankaChhetri你找到解决办法了吗请告诉我,谢谢:谢谢回复。我的问题解决了。现在布尔成功返回1。但我无法在iBook中打开此pdf。现在错误是***由于未捕获的异常“NSGenericeException”而终止应用程序,原因:“-[UIPopoverController dealloc]在popover仍然可见时到达。感谢您的回复。我的问题已解决。现在布尔成功返回1。但我无法在iBook中打开此pdf。现在错误是***由于未捕获的异常“NSGenericeException”而终止应用程序,原因:“-[UIPopoverController dealloc]在popover仍然可见时到达。