首页 > 解决方案 > 使用未声明的标识符“importMenu”

问题描述

我在编译时在目标 c 中遇到上述错误。我不知道为什么会这样。

下面是编码文件

测试.m文件

- (void)displayDocumentPicker:(NSArray *)UTIs withSenderRect:(CGRect)senderFrame
{
    UIViewController * vc = nil;
    [importMenu addOptionWithTitle:@"Photos & Videos" image:nil order:UIDocumentMenuOrderFirst handler:^{

        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

        imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
        imagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:imagePickerController.sourceType];
        imagePickerController.allowsEditing = NO;
        imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;

        imagePickerController.delegate = self;
        [self.viewController presentViewController:imagePickerController animated:YES completion:nil];

    }];
    if (!IsAtLeastiOSVersion(@"11.0")) {
        vc = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:UTIs inMode:UIDocumentPickerModeImport];
        ((UIDocumentMenuViewController *)vc).delegate = self;
        vc.popoverPresentationController.sourceView = self.viewController.view;
        if (!CGRectEqualToRect(senderFrame, CGRectZero)) {
            vc.popoverPresentationController.sourceRect = senderFrame;
        }
    } else {
        vc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:UTIs inMode:UIDocumentPickerModeImport];
        ((UIDocumentPickerViewController *)vc).delegate = self;
        vc.modalPresentationStyle = UIModalPresentationFullScreen;
    }

    [self.viewController presentViewController:vc animated:YES completion:nil];

}

测试.h文件

#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
#import <AssetsLibrary/AssetsLibrary.h>

@interface FilePicker : CDVPlugin <UIDocumentMenuDelegate,UIDocumentPickerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@property (strong, nonatomic) CDVPluginResult * pluginResult;
@property (strong, nonatomic) CDVInvokedUrlCommand * command;

- (void)isAvailable:(CDVInvokedUrlCommand*)command;
- (void)pickFile:(CDVInvokedUrlCommand*)command;

@end

我需要在 Test.h 文件中添加任何标题吗?

标签: objective-c

解决方案


Afaik,您从未定义过 importMenu。

添加类似的东西怎么样UIDocumentMenuViewController * importMenu = UIDocumentMenuViewController();,或者可能是非弃用类UIDocumentPickerViewController


推荐阅读