Xcode:通过操作表共享内容

我想复制这种行为(见下图),并从我的应用程序使用这种行动表共享内容。

在这里输入图像说明

问题是:

这真的是一个行动表吗? 我无法find任何iOS 7或8的教程。不知道如何继续。

共享选项取决于用户的configuration吗?

提示将不胜感激。

它不在UIActionSheet它是UIActivityController是iOS中的默认函数

客观-C

 - (void)presentActivityController:(UIActivityViewController *)controller { // for iPad: make the presentation a Popover controller.modalPresentationStyle = UIModalPresentationPopover; [self presentViewController:controller animated:YES completion:nil]; UIPopoverPresentationController *popController = [controller popoverPresentationController]; popController.permittedArrowDirections = UIPopoverArrowDirectionAny; popController.barButtonItem = self.navigationItem.leftBarButtonItem; // access the completion handler controller.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *error){ // react to the completion if (completed) { // user shared an item NSLog(@"We used activity type%@", activityType); } else { // user cancelled NSLog(@"We didn't want to share anything after all."); } if (error) { NSLog(@"An Error occured: %@, %@", error.localizedDescription, error.localizedFailureReason); } }; } -(void)sendMessage { //create a message NSString *theMessage = @"Some text we're sharing with an activity controller"; NSArray *items = @[theMessage]; // build an activity view controller UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil]; // and present it [self presentActivityController:controller]; } 

迅速

 let shareText = "Hello, world!" if let image = UIImage(named: "myImage") { let vc = UIActivityViewController(activityItems: [shareText, image], applicationActivities: []) presentViewController(vc, animated: true, completion: nil) } 

尝试链接教程

  1. http://nshipster.com/uiactivityviewcontroller/

  2. http://www.codingexplorer.com/add-sharing-to-your-app-via-uiactivityviewcontroller/

  3. http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/

迅速

https://www.hackingwithswift.com/example-code/uikit/how-to-share-content-with-uiactivityviewcontroller

你可以通过使用UIActivityController类来实现这个结果。

请看这个链接: http : //nshipster.com/uiactivityviewcontroller/

希望这可以帮助!