Search code examples
iosrhomobile

Undefined self.view for presentOpenInMenuFromRect


I'm trying to add the "presentOpenInMenuFromRect" functionality to Rhomobile. However, I have trouble referencing to the current view.

The Rhomobile function (### marks my additions):

- (void)openDocInteractCommand:(NSString*)url {
if (NSClassFromString(@"UIDocumentInteractionController")) {
    NSURL *fileURL = [NSURL fileURLWithPath:url];

    UIDocumentInteractionController* docController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];

    docController.delegate = self;//[AppManager instance];

    BOOL result = [docController presentPreviewAnimated:YES];

    if (!result) {
      ###
        BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
      ###
    }    
}
}

Essentially, if the preview fails, I want to open the "Open In" menu, because I;mtrying to open a .KMZ (Google Earth KML file) and it can't be previews.

Full source code: https://github.com/rhomobile/rhodes/blob/master/platform/iphone/Classes/AppManager/AppManager.m

Thanks,

Nick,


Solution

  • The AppManager class inherits from NSObject and not from UIViewController - how come it would have a property named view? You have to find another way to present your view or view controller (maybe use the application's main window).