3

Facebook でアプリを共有したいと考えています。

Facebook アカウントを構成していない場合、次のエラーが表示されます。 「設定」をタップしてもうまくいきません。「設定」と「キャンセル」は同じ結果になります。

エラー画像添付

したがって、Social.framework をインポートしました。

#import <Social/Social.h>

以下は使用した方法です。

-(IBAction) facebookBtnCall{

NSString *facebookTxt = @"Facebook Text";
NSString *AppUrl = @"http://www.google.co.in/";
NSString *ImageUrl = @"http://www.phoolwala.com/adminpanel/uploads/small/1303380733-PHW-B-18-RP-R.jpg";

float version = [[[UIDevice currentDevice] systemVersion] floatValue];

if (version >= 6.0) {

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        SLComposeViewController *fbComposer = [SLComposeViewController
                                               composeViewControllerForServiceType:SLServiceTypeFacebook];
        //set the initial text message
        [fbComposer setInitialText:facebookTxt];
        //add url
        if ([fbComposer addURL:[NSURL URLWithString:AppUrl]]) {
            NSLog(@"Blog url added");
        }

        // you can remove all added URLs as follows
        //[fbComposer removeAllURLs];

        //add image to post
        if ([fbComposer addImage:[UIImage imageNamed:ImageUrl]]) {
            NSLog(@"strong binary added to the post");
        }
        if ([fbComposer addImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:ImageUrl]]]]) {
            NSLog(@"scan is added to the post");
        }

        //remove all added images
        //[fbComposer removeAllImages];

        //present the composer to the user
        [self presentViewController:fbComposer animated:YES completion:nil];

    }
}
else {
    NSLog(@"Load facebook on webview");
}
}
4

1 に答える 1

2

次のようなことを試しましたか:

    SLComposeViewController *fbController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){

        [fbController dismissViewControllerAnimated:YES completion:nil];

        switch(result){
            case SLComposeViewControllerResultCancelled:
            default:
            {
                NSLog(@"Cancelled.....");

            }
                break;
            case SLComposeViewControllerResultDone:
            {
                NSLog(@"Posted....");
            }
                break;
        }};

    //[fbController addImage:[UIImage imageNamed:@"1.jpg"]];
    [fbController setInitialText:@"Test message"];
    [fbController addURL:[NSURL URLWithString:self.asset.url]];
    [fbController setCompletionHandler:completionHandler];
    [self presentViewController:fbController animated:YES completion:nil];
} else {
    NSLog(@"no facebook setup");
}
于 2013-01-23T16:27:41.493 に答える