社交操作表(如在 iOS 6 上)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13287007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:09:00  来源:igfitidea点击:

Social action sheet (like on iOS 6)

objective-ciosxcodeuiactionsheetsharing

提问by MCKapur

on iOS 6 a change was that when you want to share something it brings up an action sheet similar to this:

在 iOS 6 上的一个变化是,当你想分享一些东西时,它会弹出一个类似于这样的操作表:

I have seen a few other apps that use this, is there a native way to do this without making a custom action sheet?

我已经看到其他一些使用它的应用程序,是否有一种本地方法可以在不制作自定义操作表的情况下执行此操作?

Thanks!

谢谢!

回答by j9suvak

    NSString *textToShare = @"your text";
    UIImage *imageToShare = [UIImage imageNamed:@"yourImage.png"];
    NSArray *itemsToShare = @[textToShare, imageToShare];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
    [self presentViewController:activityVC animated:YES completion:nil];

See UIActivityViewController documentation: https://developer.apple.com/documentation/uikit/uiactivityviewcontroller

请参阅 UIActivityViewController 文档:https: //developer.apple.com/documentation/uikit/uiactivityviewcontroller

回答by kkocabiyik

It is actually a custom action sheet that you can easily create as well. In addition to this, you might want to look at this share kit framework.

它实际上是一个自定义操作表,您也可以轻松创建。除此之外,您可能还想看看这个共享工具包框架。

https://github.com/ShareKit/ShareKit

https://github.com/ShareKit/ShareKit