【问题标题】:Why is UIDocumentinteractioncontroller not showing a menu?为什么 UIDocumentinteractioncontroller 不显示菜单?
【发布时间】:2011-06-29 12:10:06
【问题描述】:

有一段时间我正在努力创建一个自定义的钛模块。我正在尝试在其他应用程序中打开 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");
    }
}

【问题讨论】:

  • 经过更多测试后,确实创建了菜单但不可见。然后关闭应用程序并重新打开菜单可见。这似乎是底层 viewProxy 中的布局问题

标签: objective-c uidocumentinteraction titanium-modules


【解决方案1】:

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

ENSURE_UI_THREAD_1_ARG(args);

更多详情:

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

【讨论】:

    猜你喜欢
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 2021-12-21
    • 1970-01-01
    相关资源
    最近更新 更多