UIDocumentInteractionController将无法在Ibook中打开文档

时间:2012-07-02 11:55:09

标签: objective-c ios ipad ibooks uidocumentinteraction

问题在于“成功”总是让我虚假吗?我不是什么问题?

我的代码如下:

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];

3 个答案:

答案 0 :(得分:0)

class reference documentation说:

  

返回值

     

YES如果显示选项菜单,或NO如果不显示。如果菜单中没有要包含的相应项目,则可能不会显示选项菜单。

我认为%3F1340297029上的currentPDFPath后缀可能阻止UTI匹配。

检查UTI的{​​{1}}属性,如果是docController,则设置为kUTTypePDF

答案 1 :(得分:0)

您的崩溃问题可能是因为您的docController已经发布了。您需要保留它,然后再自动发布。看看这里:

https://stackoverflow.com/a/3474825/523350

答案 2 :(得分:0)

我修改了你的代码,不是它对我有用,我使用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正在返回YESNOYES =后面的行是TRUENO如果该行是FALSE

- 大卫