且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iOS中的共享菜单中添加菜单项

更新时间:2023-11-29 23:07:58

  1. 设置project-info.plist->添加新项目(UTExportedTypeDeclarations)

  1. Set project-info.plist -> add new item (UTExportedTypeDeclarations)

<key>UTExportedTypeDeclarations</key>
<array>
<dict>
    <key>UTTypeConformsTo</key>
    <array>
        <string>com.apple.quicktime-movie</string>
    </array>
    <key>UTTypeIdentifier</key>
    <string>com.company.project</string>
    <key>UTTypeTagSpecification</key>
    <dict/>
</dict>
</array>

  • 将您的ButtonClick事件编码为.m文件

  • Coding your ButtonClick event in .m file

    -(IBAction)actionClick:(id)sender{
    
        UIDocumentInteractionController *documentController = 
              [UIDocumentInteractionController interactionControllerWithURL:
                                      [NSURL fileURLWithPath:MOVIE_FILE_PATH]];
        documentController.delegate = self;
        documentController.UTI = @"com.apple.quicktime-movie";
        [documentController presentOpenInMenuFromRect:CGRectZero 
                                               inView:self.view 
                                             animated:YES];
    }