Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create share button in iOS 9?

In my app i want to create a share button with WhatsApp,Facebook,Twitter,Mail like this.

Here is my code

-(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];
}

I'm writing this code my simulator display like this,

enter image description here

It shows only mail and facebook icons, i want whatsup icon message like this nore.

like image 712
User558 Avatar asked Jan 22 '16 06:01

User558


1 Answers

-(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];
 }
like image 54
Uma Madhavi Avatar answered Oct 10 '22 21:10

Uma Madhavi