Xcode 社交媒体分享按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12101980/
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-09-15 01:19:01  来源:igfitidea点击:

Xcode social media sharing button

objective-cxcodetwittersocial-networkingfacebook-social-plugins

提问by Toh Chin Chooi

Is there any built-in api/code for Xcode that allow the app to detect what other social media apps installed in the iphone/ipad/ipod touch to populate out the sharing features?

是否有任何用于 Xcode 的内置 api/代码允许应用程序检测安装在 iphone/ipad/ipod touch 中的其他社交媒体应用程序以填充共享功能?

I was told that Android has such capability, so does iOS have it too?

有人告诉我 Android 有这样的能力,那么 iOS 也有吗?

回答by ElasticThoughts

Twitter integration is built into iOS 5, check this link http://developer.apple.com/library/ios/documentation/Twitter/Reference/TWTweetSheetViewControllerClassRef/Reference/Reference.html

Twitter 集成内置于 iOS 5 中,请查看此链接http://developer.apple.com/library/ios/documentation/Twitter/Reference/TWTweetSheetViewControllerClassRef/Reference/Reference.html

For Facebook you need to use the Facebook SDK, check here http://developers.facebook.com/docs/reference/iossdk/

对于 Facebook,您需要使用 Facebook SDK,请在此处查看http://developers.facebook.com/docs/reference/iossdk/

Alternatively you could try ShareKit... http://getsharekit.com/

或者,您可以尝试 ShareKit ... http://getsharekit.com/

Or GetSocialize... http://www.GetSocialize.com/

或 GetSocialize ... http://www.GetSocialize.com/

Both of these offer drop in functionality.

这两者都提供了功能下降。

回答by Bailasan Hasan

- (IBAction) shareHasTapped: (id)sender {

    NSString *texttoshare = @"text to share";

    //  UIImage *imagetoshare = [UIImage imageNamed:@"beck.png"];

    NSArray *activityItems = @[texttoshare];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

    activityVC.excludedActivityTypes =@[UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];


[self presentViewController:activityVC animated:TRUE completion:nil];

}

}

回答by Ramani Hitesh

Share Image Social Network Using UIActivityViewController:

使用 UIActivityViewController 共享图像社交网络:

-(void)shareimage {

-(void)shareimage {

NSArray *objectsToShare = @[_s_image];
UIActivityViewController * avc = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

avc.excludedActivityTypes=@[UIActivityTypePostToTwitter];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    [self presentViewController:avc animated:YES completion:nil];
}
else
{
    UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:avc];
    [popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

}

}