- (IBAction)btnSharePressed:(id)sender { //filePath must NSURL object and looking like this => file:///Users/simon/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/A5321493-318A-4A3B-8B37-E56B8B4405FC/AirDropDemo.app/ios-game-kit-sample.pdf NSString *filePath = [NSString stringWithFormat:@"file://%@",[self getFilePath:@"ios-game-kit-sample.pdf"]]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[filePath] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:nil]; }
Above code share the document with all available share option, if we want to remove some option use below code.
- (IBAction)btnSharePressed:(id)sender { //filePath must NSURL object and looking like this => file:///Users/simon/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/A5321493-318A-4A3B-8B37-E56B8B4405FC/AirDropDemo.app/ios-game-kit-sample.pdf NSString *filePath = [NSString stringWithFormat:@"file://%@",[self getFilePath:@"ios-game-kit-sample.pdf"]]; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[filePath] applicationActivities:nil]; // Exclude all activities except AirDrop. NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook, UIActivityTypePostToWeibo, UIActivityTypeMessage, UIActivityTypeMail, UIActivityTypePrint,UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr, UIActivityTypePostToVimeo,UIActivityTypePostToTencentWeibo]; activityViewController.excludedActivityTypes = excludedActivities; [self presentViewController:activityViewController animated:YES completion:nil]; }
for image share use this option
- (IBAction)btnShareApp:(id)sender { UIImage *shareImage = imgView.image; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[shareImage] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:nil]; }
No comments:
Post a Comment