问题在于“成功”总是让我虚假吗?我不是什么问题?
我的代码如下:
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];
答案 0 :(得分:0)
class reference documentation说:
返回值
YES
如果显示选项菜单,或NO
如果不显示。如果菜单中没有要包含的相应项目,则可能不会显示选项菜单。
我认为%3F1340297029
上的currentPDFPath
后缀可能阻止UTI匹配。
检查UTI
的{{1}}属性,如果是docController
,则设置为kUTTypePDF
。
答案 1 :(得分:0)
您的崩溃问题可能是因为您的docController已经发布了。您需要保留它,然后再自动发布。看看这里:
答案 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
正在返回YES
或NO
,YES
=
后面的行是TRUE
和NO
如果该行是FALSE
。
- 大卫