Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:47:33+00:00 2026-06-12T14:47:33+00:00

Finally been making it through Apple’s (rather dismal) documentation on the new UIActivityViewController class

  • 0

Finally been making it through Apple’s (rather dismal) documentation on the new UIActivityViewController class and the UIActivityItemSource protocol, and I’m trying to send different data sets to different actions called from the activity view. To simplify things, I’m looking at two things.

  1. A Facebook posting action, which should say “Check this out!” and also attach a URL to the post (with that cute little paperclip).
  2. A Twitter posting action, which should say “Check this out, with #hashtag!” and also attach that same URL (with the same paperclip).

Here’s the code I’ve got implemented right now.

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
        return @"Check this out!";
    } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
        return @"Check this out, with #hashtag!";
    }

    return @"";
}

- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return @"";
}

And then when I set up this activity view controller (it’s in the same class), this is what I do.

UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:nil];
[self presentViewController:activityView animated:YES completion:nil];

My dilemma is how to attach that NSURL object. It’s relatively easy when calling the iOS 6 SL-class posting modals; you just call the individual methods to attach a URL or an image. How would I go about doing this here?

I’ll note that instead of returning NSString objects from -activityViewController:itemForActivityType, if I return just NSURL objects, they show up with that paperclip, with no body text in the post. If I return an array of those two items, nothing shows up at all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:47:34+00:00Added an answer on June 12, 2026 at 2:47 pm

    Evidently it was as simple as this: passing in an array to the first argument of UIActivityViewController‘s init call, with each item in the array handling a different data type that will end up in the compose screen. self handles the text, and the second object (the NSURL) attaches the URL.

    NSArray *items = @[self, [NSURL URLWithString:@"http://this-is-a-url.com"]];
    UIActivityViewController *activityView = [[UIActivityViewController alloc]  initWithActivityItems:items applicationActivities:nil];
    [self presentViewController:activityView animated:YES completion:nil];
    

    Really wish there was more on this, but here it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been making increasingly heavy use of the new @Bean configuration style in Spring
I have been making a live wallpaper and have finally succeeded so far, but
For my mobile programming course we've finally been given some free reign to design
EDIT : As of 2012-06-11 this bug has been finally fixed! https://bugs.webkit.org/show_bug.cgi?id=35981#c1 I have
I am learning to use mysql for rails apps, and I finally have been
I've been messing around with some coding and finally think I'm finally ready for
I've been stuck on this for ever and I finally figured it out and
EDIT I have finally figured out the problem i have been having on my
I have been using DotNetOpenAuth v3.5.0.10357 for about a year now and finally decided
From within a finally block, is it possible to tell an exception has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.