Objective c 使用未声明的标识符';导入菜单';
在编译时,我在objective c中遇到了上述错误。我不知道为什么会出现这种情况 下面是编码文件 Test.m文件Objective c 使用未声明的标识符';导入菜单';,objective-c,Objective C,在编译时,我在objective c中遇到了上述错误。我不知道为什么会出现这种情况 下面是编码文件 Test.m文件 - (void)displayDocumentPicker:(NSArray *)UTIs withSenderRect:(CGRect)senderFrame { UIViewController * vc = nil; [importMenu addOptionWithTitle:@"Photos & Videos" image:nil order:U
- (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];
}
#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文件
- (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];
}
#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
#导入
#进口
#进口
@接口文件选择器:CDVPlugin
@属性(强,非原子)CDVPluginResult*pluginResult;
@属性(强,非原子)CDVInvokedUrlCommand*命令;
-(void)可用:(CDVInvokedUrlCommand*)命令;
-(void)pickFile:(CDVInvokedUrlCommand*)命令;
@结束
是否需要在Test.h文件中添加任何标题?好的,您从未定义过importMenu
添加类似于
UIDocumentMenuViewController*importMenu=UIDocumentMenuViewController()的内容如何代码>,或者可能是未弃用的类UIDocumentPickerViewController
?在哪里声明importMenu?