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

4

我刚开始接触iOS开发,但是我需要尽早在系统菜单中添加一个按钮,就像Dropbox在处理电子邮件附件时添加了它的按钮。

这个应用程序是用于视频的,因此在快速时间播放器的共享菜单中添加一个按钮是理想的。

我已经查阅了文档,只找到了UIMenuItem类。这是我想要的吗?还是有其他实现此功能的方法?

1个回答

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接