【问题标题】:How do I add a menu item to the share menu in iOS如何将菜单项添加到 iOS 中的共享菜单
【发布时间】:2012-08-06 11:04:59
【问题描述】:

我刚刚开始进行 iOS 开发,但我必须尽早在系统菜单中添加一个按钮,例如 Dropbox 在与电子邮件附件交互时添加按钮的方式。

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

我浏览了文档,只找到了 UIMenuItem 类。这是我想要的还是有其他方法可以实现此功能?

【问题讨论】:

    标签: iphone objective-c ios menu


    【解决方案1】:
    1. 设置 project-info.plist -> 添加新项目(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. 在 .m 文件中编写 ButtonClick 事件

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      相关资源
      最近更新 更多