You can share text, images and urls using this function:
- (void)shareText:(NSString *)text andImage:(UIImage *)image andUrl:(NSURL *)url{
NSMutableArray *sharingItems = [[NSMutableArray alloc] init];
if (text) {
[sharingItems addObject:text];
}
if (image) {
[sharingItems addObject:image];
}
if (url) {
[sharingItems addObject:url];
}
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
//need for iPads. Add subview in bottom to set the start to share view
CGRect mainFrame = [[UIApplication sharedApplication].keyWindow.rootViewController view].frame;
UIView *sourceView = [[UIView alloc] initWithFrame: CGRectMake(mainFrame.size.width/2, mainFrame.size.height, 0, 0)];
[[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:sourceView];
activityController.popoverPresentationController.sourceView = sourceView;
// Present share view
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:activityController animated:YES completion:nil];
}
Usage example
[self shareText:nil andImage:nil andUrl: yourUrl]
This will share only your url.
Result
