在我的应用程序中,我想像这样使用 WhatsApp、Facebook、Twitter、Mail 创建一个共享按钮。
这是我的代码
-(IBAction)share:(id)sender
{
NSString *shareText = @"Hi This is a Reward Game App";
NSArray *itemsToShare = @[shareText];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypePostToTwitter,UIActivityTypePostToFacebook,UIActivityTypeMail,UIActivityTypeMessage,UIActivityTypeAssignToContact,UIActivityTypePostToTencentWeibo];
[self presentViewController:activityVC animated:YES completion:nil];
}
我正在编写这段代码,我的模拟器显示如下,
它只显示邮件和 Facebook 图标,我想要这样的 whatsup 图标消息。
最佳答案
试试这个
-(IBAction)shareAction:(id)sender
{
NSArray* sharedObjects=[NSArray arrayWithObjects:@"sharecontent", nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];
}
关于ios - 如何在 iOS 9 中创建分享按钮?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34940459/