Recreate/Use the default iPhone Photo app save menu - ios

I want to save a photo with the same options given by the default iPhone photo app as seen in this picture:

You can do this using UIActivityViewController. You can create a UIActivityViewController, pass it an image, or the URL to an image, and optionally tell it to exclude certain activities that you don't want to appear. Then, present it, as you would any other viewController.
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[ myImage ] applicationActivities:nil];
activityViewController.excludedActivityTypes = #[ UIActivityTypeAssignToContact ];
activityViewController.completionHandler = ^(NSString *activityType, BOOL completed){
// handle completion
};
[self presentViewController:activityViewController animated:YES completion:nil];
Check out the documentation for more info.

Related

Change activity items base on which application is selected for sharing in iOS

I share an image with text to othe applications.
NSArray *activityItems = #[title, finalImage];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
Problem with this code is that I share title and image for all destination apps. but for instance, WhatsApp has problem when I share image with title. When I delete title it will correctly share the image but when I add title to activityItems, it just sends title. I want to detect if whats app is selected and then just send the image

iOS share sheet scale modification

I'm writing my app on iOS 9.3. However, my app's share sheet screen is bigger than the other app's share sheet screen. Is there any way to modify the share sheet screen to the iPhone original icons size?
Following are my code:
- (IBAction)onShareButtonClick:(UIButton *)sender {
NSString *string = #"Upload Chart";
UIImage *uploadImage = [self.selectedController performSelector:#selector(getUploadImage)];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:#[string, uploadImage] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];}
As the comment below, I found that getUploadImage is only getting the part of the screen.
if I modify the code as follow, the share sheet would be only "more more" instead. However, the size of the share icon is the same as the origin.
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityVC applicationActivities:nil];
Because the activityVC is empty.

ActivityItems in UIActivityViewController don't show up

I'm developing an app in iOS 7 and in it I need to show an activity controller. Below is my code,
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:#[UIActivityTypeSaveToCameraRoll, UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypeMail, UIActivityTypeMessage, UIActivityTypePrint] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
But when its presented, this is how it looks.
None of the activity types I added in the array shows up. Why is this happening? Am I missing something? I'd like some help to get this working. I especially need the Facebook, twitter sharing and the saving to the local storage options here.
Thank you.
Edit: I checked on a real device and the Facebook and Twitter sharing options show up. However UIActivityTypeSaveToCameraRoll, UIActivityTypePrint still aren't showing up.
The Items will show up only if you have integrated them to your Device.
If you have integrated facebook and Logged into facebook in the settings then Facebook will appear along the Items. That means your device must be Synchronised with the native Facebook, Twitter, etc Apps for them to show up in the UIActivityViewController
Edit:
Try using like this
UIActivityViewController *ActivityView;
ActivityView =
[[UIActivityViewController alloc]
initWithActivityItems:Items applicationActivities:nil];
[self presentViewController:ActivityView animated:YES completion:nil];

UIActivityViewController: PostToTwitter: text can´t be changed in presented modal View

i have a problem with iOS 6´s UIActivityViewController. I want to share an image and a text.
When i share it via Facebook, the text is editable in the modal view. In Twitter, i can't change the text. is there a way to change it for Twitter, so that the text is editable ?
This is my code:
NSArray *activityItems = #[#"Test Text",resultImage];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeMessage,UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:YES completion:nil];

uiactivityviewcontroller from toolbar

I´m trying to use the following code in my app to get the uiactivityviewcontroller, and it works if I set up a round rect button, but not with a UIBarButtonItem? Am I missing something really simple here?
- (IBAction)shareIt:(id)sender {
NSArray *activityItems;
activityItems = #[_textView.text];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
}
I'm guessing (read: I'm sure) that this is happening because you didn't hook up the action to the barButtonItem correctly in code. If you are making it in code, you can use this:
UIBarButtonItem *bBI = ...; //get it
[bBI setTarget:self];
[bBI setAction:#selector(shareIt:)];

Resources