gpt4 book ai didi

ios - presentOpenInMenuFromRect 的未定义 self.view

转载 作者:行者123 更新时间:2023-11-29 11:09:23 25 4
gpt4 key购买 nike

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

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

谢谢,

尼克,

最佳答案

这是解决我问题的代码:

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

关于ios - presentOpenInMenuFromRect 的未定义 self.view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12222940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com