1

我正在尝试将“presentOpenInMenuFromRect”功能添加到 Rhomobile。但是,我无法引用当前视图。

Rhomobile 功能(### 标记我的补充):

- (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];
      ###
    }    
}
}

本质上,如果预览失败,我想打开“打开方式”菜单,因为我正在尝试打开一个 .KMZ(Google 地球 KML 文件)并且它不能是预览。

完整源代码:https ://github.com/rhomobile/rhodes/blob/master/platform/iphone/Classes/AppManager/AppManager.m

谢谢,

缺口,

4

2 回答 2

2

这是解决我的问题的代码:

  - (void)openDocInteractCommand:(NSString*)url { // inView:(UIView*)view
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) {
        [docController retain];
        CGPoint centerPoint = [Rhodes sharedInstance].window.center;
        CGRect centerRec = CGRectMake(centerPoint.x, centerPoint.y, 0, 0);
        BOOL isValid = [docController presentOpenInMenuFromRect:centerRec inView:[Rhodes sharedInstance].window animated:YES];
    }
}
}

- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)docController
{
[docController autorelease];
}
于 2012-09-01T13:37:36.883 回答
1

AppManager 类继承自 NSObject 而不是 UIViewController - 它怎么会有一个名为的属性view?您必须找到另一种方式来呈现您的视图或视图控制器(可能使用应用程序的主窗口)。

于 2012-08-31T22:02:49.253 回答