Sunday 16 June 2013

How to post Facebook Status from iOS App..?



1. Add SocialFramework from libraries
2. Import header file to ViewController.h
3. Create one button using Interface Builder, make connection to ViewContoller.m
4. Paste below code in ViewController.h in ViewDidLoad method


- (IBAction)postFacebook:(UIButton *)sender {
 
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
        SLComposeViewController *controller=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        [controller setInitialText:@""];
        [self presentViewController:controller animated:YES completion:nil];
    }