For a while I’m strugeling creating a custom titaniummodule. I’m trying to open a pdf in an otrher app.
Everything seems to be correct (no warnings etc)
But there is no menu showing when pressing the button in de navBar.
Here is the code of the method showing the menu:
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");
}
}
Module methods run on a non-UI thread, however, all UIKit methods must be executed on the main UI thread. You need ensure that your method is running on the UI thread with the macro:
More details on:
https://wiki.appcelerator.org/display/guides/iOS+Module+Development+Guide#iOSModuleDevelopmentGuide-AddingSpecialCompilerDirectives