I'm trying to use UIActivityController in my app. Unfortunately the size of the modal is far too large.
On the left, the modal I want, on the right, the modal I have :
And here is the code I use to display the modal when I click on the Share button :
NSString *textToShare = #"Hello !";
NSURL *myWebsite = [NSURL URLWithString:#"http://stackoverflow.com/"];
NSArray *objectsToShare = #[textToShare, myWebsite];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
// Email subject
[activityVC setValue:#"Hello !" forKey:#"subject"];
[self presentViewController:activityVC animated:YES completion:nil];
What am I doing wrong ?
Thanks in advance.
You're doing nothing wrong, you're just using a differently sized device! Try running in the simulator using iPhone 6 or iPhone 6S and I bet you'll see exactly what you want on the left. Looks like you're just running it on a smaller device than what you want.
Related
I encounter this bug when using UIActivityViewController in order to create a simple UI for sharing assets in my app. This works well on ios 10 and above, but in ios 9 this annoy issue appears. I've already researched for solutions but didn't find any help. Could you guys please take a look?
My code is just simple as below:
NSString *url=#"http://itunes.apple.com/us/app/APPNAME/idXXXXXXXXX";
NSString * title =[NSString stringWithFormat:#"Download ECG app %# and get free reward points!",url];
NSArray* dataToShare = #[title];
UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
activityViewController.excludedActivityTypes = #[UIActivityTypeAirDrop];
[self presentViewController:activityViewController animated:YES completion:^{}];
In ios 9, it looks like THIS
Please try to update animated:NO when you present the Activity View, if the view displayed correctly with animated:NO then self.view.translatesAutoresizingMaskIntoConstraints = NO; should be the cause of this problem.
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.
I'm currently implementing an iOS app using objective-C, which has a function that users may share a file with other friend or other app (like upload the file to Dropbox, Google Drive, attach the file to Mail, share the file to Facebook Messenger, Whatsapp, via Bluetooth, etc).
Is there a native way to implement this share function that can detect all apps which allows sharing a file, while I don't need to do it one by one?
You want to use UIActivityViewController. Below is an example from NSHipster, which is probably the most comprehensive article I've seen on the subject. And Apple has some good documentation here.
NSString *string = ...;
NSURL *URL = ...;
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[string, URL]
applicationActivities:nil];
[navigationController presentViewController:activityViewController
animated:YES
completion:^{
// ...
}];
This provide full answer for iPhone and iPad devices
ViewController *contentViewController = [[ViewController alloc] init];
// Present the view controller using the popover style.
contentViewController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:contentViewController
animated:YES
completion:nil];
// Get the popover presentation controller and configure it.
UIPopoverPresentationController *presentationController =[contentViewController popoverPresentationController];
presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
presentationController.sourceView = self.view;
presentationController.sourceRect = self.view.frame;
UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs on iOS 9
I've a problem with the UIActivityController on iOS 8 iPad: the activity view works correctly I can select a share service (i.e. Twitter) but when the "publish" view appear I can only click on the Post button,the Cancel button doesn't work. I've the same problem on real devices and on the simulator.
If you have an idea about how to fix this problem,...
Thanks
Here's my code:
- (IBAction)activityController:(id)sender {
// items to share
NSURL *url = [NSURL URLWithString:_articleUrl];
NSArray *items=#[url];
// create the controller
UIActivityViewController *controller = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
UIPopoverPresentationController *popPC = controller.popoverPresentationController;
popPC.barButtonItem = _buttn;
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
I'd like to create very similar sliding up menu as share/bookmark/copy/paste menu in iOS7 Safari.
What is the best way of building it?
Is there any ready made template in XCode or do I have to follow the same principle as when building the slide left/right hamburger menu?
example action:
-(IBAction)sendPost:(id)sender {
NSArray *activityItems;
activityItems = #[#"example share / copy text"]; //needs to be an array because you //could add pictures additionally
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController
animated:YES completion:nil];
}