如何在iOS中的共享菜单中添加菜单项 [英] How do I add a menu item to the share menu in iOS

查看:394
本文介绍了如何在iOS中的共享菜单中添加菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚进入iOS开发,但是我必须尽早做的是在系统菜单中添加一个按钮,例如Dropbox如何在与电子邮件附件进行交互时添加其按钮.

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.

此应用程序将用于视频,因此在共享菜单上为QuickTime播放器添加一个按钮将是理想的选择.

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

我已经仔细阅读了文档,仅找到了UIMenuItem类.这是我想要的还是实现该功能的另一种方法?

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

  • 这篇关于如何在iOS中的共享菜单中添加菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆