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 8553533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:40:28+00:00 2026-06-11T14:40:28+00:00

What are the steps I need to follow to use iOS 6’s new SLComposeViewController

  • 0

What are the steps I need to follow to use iOS 6’s new SLComposeViewController to post to Facebook, Twitter or Sina Weibo?

  • 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-11T14:40:29+00:00Added an answer on June 11, 2026 at 2:40 pm

    For details on this framework please see Apple’s Social Framework Class Reference

    Additional tutorials:

    1. http://soulwithmobiletechnology.blogspot.com/2012/07/tutorial-how-to-use-inbuilt.html
    2. http://www.mobile.safilsunny.com/iphone/integrating-facebook-ios/
    3. https://rudeboy-quickies.blogspot.com/2012/06/steps-to-integrate-facebook-in-ios6.html

    For this example, we will be using the SLComposeViewController‘s SLServiceTypeFacebook. If you wish to use Twitter or SinaWeibo just change out the SLServiceType to one of the following:

    • SLServiceTypeFacebook
    • SLServiceTypeSinaWeibo
    • SLServiceTypeTwitter

    iOS 6 has made it very easy to post directly to Facebook, Twitter or Sina Weibo using the SLComposeViewController. This works very similarly to iOS 5’s TWTweetComposeViewController.

    First, in your view controller’s header file (.h) #import the Social Framework and the Accounts Framework.

    #import <Social/Social.h>

    #import <Accounts/Accounts.h>

    Here we will declare a simple UIButton and an IBAction that we will later link to that button and a void (sharingStatus) which will be used to check that the selected sharing service is available.

    @interface ViewController : UIViewController
    
    @property (weak, nonatomic) IBOutlet UIButton *easyFacebookButton;
    - (IBAction)facebookPost:(id)sender;
    - (void)sharingStatus;
    @end
    
    @implementation ViewController
    

    Then, in your implementation file (.m), we’ll start by implementing the (sharingStatus) void that we declared in the header file. sharingStatus uses SLComposeViewController‘s isAvailableForServiceType BOOL to return whether or not you can post to the service specified in its argument. In this case, we will use the service type SLServiceTypeFacebook. If the service is available the post button will be enabled with an alpha value of 1.0f, and if the service isn’t available the button will be disabled its alpha value set to 0.5f.

    - (void)sharingStatus {
        if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
            NSLog(@"service available");
            self.easyFacebookButton.enabled = YES;
            self.easyFacebookButton.alpha = 1.0f;
        } else {
            self.easyFacebookButton.enabled = NO;
            self.easyFacebookButton.alpha = 0.5f;
        }
    }
    

    Here we will set up the IBAction that will call up the composer. For good practice, we will check isAvailableForServiceType again to avoid calling up the composer for a service type that isn’t available. (Incase something went wrong during the last check, or if availability somehow changed in the fraction of a second in between tapping the post button and the composers all/init. The code below has been set up to display a Facebook composers sheet with text, an image, and a link. This action also utilises a completion handler for the composer’s cancelled and done results.

    - (IBAction)facebookPost:(id)sender {
    
        if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    
            SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    
            [mySLComposerSheet setInitialText:@"iOS 6 Social Framework test!"];
    
            [mySLComposerSheet addImage:[UIImage imageNamed:@"myImage.png"]];
    
            [mySLComposerSheet addURL:[NSURL URLWithString:@"http://stackoverflow.com/questions/12503287/tutorial-for-slcomposeviewcontroller-sharing"]];
    
            [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
    
                 switch (result) {
                     case SLComposeViewControllerResultCancelled:
                         NSLog(@"Post Canceled");
                         break;
                     case SLComposeViewControllerResultDone:
                         NSLog(@"Post Sucessful");
                         break;
    
                     default:
                         break;
                 }
             }];
    
            [self presentViewController:mySLComposerSheet animated:YES completion:nil];
        }
    }
    

    In viewWillAppear we will register an observer to ACAccountStoreDidChangeNotification so the application can be notified when account information changes. This observer will then be removed in viewDidDisappear.

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sharingStatus) name:ACAccountStoreDidChangeNotification object:nil];
    }
    
    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
        [[NSNotificationCenter defaultCenter] removeObserver:ACAccountStoreDidChangeNotification];
    }
    

    And finally, open up interface builder and add a UIButton which will be the post button. Then in the connections inspector link the IBOutlet and IBAction we created earlier to the button, and that’s it! You’re done!

    enter image description here

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

Sidebar

Related Questions

Can you please tell me the steps I need to follow in order to
What are the steps need to follow to encrypt, sign, decrypt and verify signature
Very new to XSL (and XML for that matter), but I need to step
this is a follow-up question to my last one here: iOS: Initialise object at
Say I follow these steps in svn: rev 1: create a file called 'foo'
This is a follow-up from VIM: simple steps to create syntax highlight file -
I need to convert an app from sqlite to Postgresql in order to use
this is a follow-up question to my last one here: iOS: Initialise object at
I need to do this but one step leads me to uncheck the Allow
I need to extend the Magento shopping cart to include an extra step for

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.