0

有一段时间我正在努力创建一个自定义的钛模块。我正在尝试在其他应用程序中打开 pdf。一切似乎都是正确的(没有警告等)但是在导航栏中按下按钮时没有显示菜单。

这是显示菜单的方法的代码:

ENSURE_SINGLE_ARG_OR_NIL(args,NSDictionary);

TiViewProxy* viewAnchor = [args objectForKey:@"view"];
NSString* fileToOpen = [args objectForKey:@"url"];



NSLog(@"%@",fileToOpen);

if(viewAnchor != nil){
    NSLog(@"viewAnchor is not nil accessing controller");
    NSLog(@"%@",[TiUtils toURL:fileToOpen proxy:self]);

    CGRect rect = [TiUtils rectValue:args];
    self.controller = [[UIDocumentInteractionController interactionControllerWithURL:[TiUtils toURL:fileToOpen proxy:self]] retain];
    self.controller.delegate = self;

    BOOL menuDisplayed = [self.controller presentOpenInMenuFromBarButtonItem:[viewAnchor barButtonItem] animated:YES];

    //menuDisplayed = YES
    if(menuDisplayed)
    {
        NSLog(@"Menu is displayed");
        //This display's com.adobe.pdf
        NSLog(@"%@",self.controller.UTI);
    }
    else
    {
        NSLog(@"Menu failed to display");
    }
}
4

1 回答 1

0

模块方法在非 UI 线程上运行,但是,所有 UIKit 方法都必须在主 UI 线程上执行。您需要确保您的方法使用宏在 UI 线程上运行:

ENSURE_UI_THREAD_1_ARG(args);

更多详情:

https://wiki.appcelerator.org/display/guides/iOS+Module+Development+Guide#iOSModuleDevelopmentGuide-AddingSpecialCompilerDirectives

于 2012-05-25T00:35:47.460 回答