1.判断是否支持多窗口,多窗口仅仅支持Ipad和MacOS

[UIApplication sharedApplication].supportsMultipleScenes   

 

2.判断是否为catalyst环境

[[NSProcessInfo processInfo] isMacCatalystApp]

 

3.关于MacOS左上角的Menu

- (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder API_AVAILABLE(ios(13.0))

[[UIMenuSystem mainSystem] setNeedsRebuild];

 

4.鼠标右击事件添加

if (@available(iOS 13.0, *)) {
            UIContextMenuInteraction *contextMenuInteraction = [[[UIContextMenuInteraction alloc] initWithDelegate:self] autorelease];
            [self.view addInteraction:contextMenuInteraction];

}

 

- (UIContextMenuConfiguration *)contextMenuInteraction:(UIContextMenuInteraction *)interaction configurationForMenuAtLocation:(CGPoint)location
{

   return nil

}

 

5.Mac中导入本地文件.图片等

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.plain-text",@"public.png",@"public.jpeg",@"com.compuserve.gif",@"public.tiff",@"com.microsoft.bmp",@"dyn.age81k6xg",@"com.microsoft.excel.xls",@"com.microsoft.word.doc",@"com.apple.property-list",@"com.adobe.pdf",@"public.rtf",@"public.audiovisual-content",@"com.apple.rtfd"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];

 

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls API_AVAILABLE(ios(11.0))
{
    NSURL *uurl = urls[0];
    NSString *urlss = [uurl absoluteString];

    NSString *typeStr = [[[urlss componentsSeparatedByString:@"/"] lastObject] pathExtension];
    NSString *fileType = [typeStr uppercaseStringWithLocale:[NSLocale currentLocale]];

}

 

6.获得状态栏的高度.present出来控制器后,需要知道状态栏的高度(如图红框中).可以通过navigationBar来获得.  self.navigationBar.frame.

 

7.通过UIDocumentPickerViewController导入Mac中的文件,报错ERROR: Unable to display open panel: your app is missing the User Selected File Read app sandbox entitlement. Please ensure that your app's target capabilities include the proper entitlements.

   需要打开sandbox read/write 权限

 

posted on 2022-05-05 14:39  代码少年_夕阳  阅读(212)  评论(0编辑  收藏  举报