问题
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:
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>
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