objective-c - 使用未声明的标识符“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 文件中添加任何标题吗?
解决方案
Afaik,您从未定义过 importMenu。
添加类似的东西怎么样UIDocumentMenuViewController * importMenu = UIDocumentMenuViewController();
,或者可能是非弃用类UIDocumentPickerViewController
?
推荐阅读
- c++ - 将可变参数模板参数转换为静态 constexpr 数组
- python - 正则表达式搜索中间有日期的文件
- highcharts - Highchart sankey-独立显示多个具有相同名称的条目
- excel - Outlook VBA 代码更新工作表后 Excel 文档锁定为只读
- mysql - 插入新行时自动更新 MySQL 行
- php - 正则表达式从字符串中删除特定的样式标签
- java-8 - 如何在 Project Reactor 中缓存项目并避免缓存踩踏?
- regex - 解析目录中包含与一组字符串匹配的文件 - 将匹配线拉到新文件
- python - 如何以这种方式对二维列表中的元素进行排序?
- ffmpeg - 使用 libavcodec 将视频解码为 YUV422