Question

I've added an activity view controller to allow sharing a picture from my app to various social media apps, including Sina Weibo. I have the Weibo app installed on my iPhone5 and I'm logged into it and it shows up in the activity view controller fine.

Facebook sharing from the activity view controller works but I get the following message when trying to post to Weibo:

"Cannot Send Weibo. The weibo "Check this out!" cannot be sent because the connection to Sina Weibo failed."

Here's the code:

- (IBAction)shareButtonPressed:(id)sender
{
    NSString *shareString = @"Check this out!";
    UIImage *shareImage = [self captureView:self.view];

    NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, nil];

    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
    activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypeAirDrop];

    [self presentViewController:activityViewController animated:YES completion:nil];

- (UIImage*)captureView
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    UIGraphicsBeginImageContextWithOptions(screenRect.size, NO, 0.0);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

I can get it to share if I remove the shareImage item but would like to include the image as it's the main thing being shared. Image size is only 142KB.

Any ideas how I can get it working?

Was it helpful?

Solution

Not sure why this wasn't working in iOS 7.0.5 but as soon as I updated to 7.0.6 I was able to post images to Weibo without any issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top