How do I add a menu item to the share menu in iOS

こ雲淡風輕ζ 提交于 2020-01-24 05:45:07

问题


I'm just getting into iOS development, but something I'm going to have to do early on is add a button to the system menus like how Dropbox has added its button when interacting with email attachments.

This application will be for video so adding a button on the share menu for quicktime players would be ideal.

I've scoured the documentation and have only found the UIMenuItem class. Is this what I want or is there another way to implement this functionality?


回答1:


  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>
    
  2. 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];
    }
    


来源:https://stackoverflow.com/questions/11552978/how-do-i-add-a-menu-item-to-the-share-menu-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!