【问题标题】:Converting a code from Swift to Objective C?将代码从 Swift 转换为 Objective C?
【发布时间】:2018-04-08 18:55:28
【问题描述】:

我开始直接使用 Swift 开发应用程序,所以我对 Objective C 知之甚少,但是我不得不着手一个用 Objective C 实现的项目并修复一些错误。

我在 Swift 中遇到了一个我想转换为 Objective C 的代码

func mySpecialFunction(){

let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import)
            importMenu.delegate = self
            importMenu.modalPresentationStyle = .formSheet       
            self.present(importMenu, animated: true, completion: nil)
}

现在我做了一些研究并得到了这个

UIDocumentMenuViewController *importMenu = *Code Here* ;
importMenu.delegate = self;
importMenu.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:importMenu animated:YES];

谁能帮助我如何将代码中的第一行转换为Objective C?

【问题讨论】:

标签: ios objective-c swift


【解决方案1】:
UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[@"public.item", (__bridge NSString *) kUTTypeContent, (__bridge NSString *) kUTTypeData, (__bridge NSString *) kUTTypePackage, (__bridge NSString *) kUTTypeDiskImage, @"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"] inMode:UIDocumentPickerModeImport];

使用上面的代码

【讨论】:

    【解决方案2】:

    请试试这个。

     UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(__bridge NSString*)kUTTypeContent] inMode:UIDocumentPickerModeImport];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多