Reputation: 8608
I've tried searching endlessly and I can't find a solution. I want to allow my user to share and image and some text through Facebook, Twitter, SMS, and Email. I can't seem to get UIActivityViewController
to work correctly though.
First off:
Here is how I create UIActivityViewController
:
- (IBAction)shareSelected:(id)sender {
NSMutableArray *activityItems;
//Add an image if one exist
if (self.property.images.count > 0) {
UIImageView *imageView = (UIImageView*)[self.scrollView panelAtIndex:0];
if (imageView.image)
[activityItems addObject:imageView.image];
}
//Set text
[activityItems addObject:[NSString stringWithFormat:@"I like this property! %@", [self addressCityStateZipFormatted]]];
//Set URL
[activityItems addObject:[NSURL URLWithString:@"http://www.google.com"]];
//Create controller
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityController.excludedActivityTypes = @[UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll];
//Present
[self presentViewController:activityController
animated:YES completion:nil];
}
However, this is all that gets displayed on my device:
I don't understand why it's not showing any options and why it's full screen instead of action sheet size height.
Upvotes: 0
Views: 1374
Reputation: 101
You aren't initializing activityItems:
NSMutableArray *activityItems;
Change it to
NSMutableArray *activityItems = [NSMutableArray array];
and you may have more success.
Upvotes: 2