Home » iOS » iPad » iPhone » Facebook compose sheet view like in iOS 6 for iOS 4 and above

Facebook compose sheet view like in iOS 6 for iOS 4 and above


Project based on DETweetComposeViewController

Facebook connection with Facebook SDK 3.0.x (last at 2 september 2012)

What is it?
DEFacebookComposeViewController is an iOS 4 compatible composer view for posting picture and message on user wall.
Looks like the Facebook Sheet in iOS 6.

How to use:
1. download and setup Facebook sdk https://developers.facebook.com/ios/

2. register your app on http://developers.facebook.com

3. replace appID in plist file. FacebookAppID and in CFBundleURLTypes

4. #import “DEFacebookComposeViewController.h”

5. use this code for posting

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 DEFacebookComposeViewControllerCompletionHandler completionHandler = ^(DEFacebookComposeViewControllerResult result) {
        switch (result) {
            case DEFacebookComposeViewControllerResultCancelled:
                NSLog(@"Facebook Result: Cancelled");
                break;
            case DEFacebookComposeViewControllerResultDone:
                NSLog(@"Facebook Result: Sent");
                break;
        }
       
        [self dismissModalViewControllerAnimated:YES];
    };
   
    DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [facebookViewComposer setInitialText:@"Look on this"];
    [facebookViewComposer addImage:[UIImage imageNamed:@"1.jpg"]];
    facebookViewComposer.completionHandler = completionHandler;
    [self presentViewController:facebookViewComposer animated:YES completion:^{ }];

Comments are closed.