5

私は、ユーザーが自分のアプリの詳細をFacebookに共有できるようにするアプリに取り組んでいます。UITableviewがあり、著者名のリストが含まれています。本の名前をクリックすると、別のUITableviewに移動しUITableView、それぞれにその著者の異なる本が表示されますTableViewCell。2番目にリストを表示することができますUITableView。著者名、本名、画像(2番目のテーブルビューの詳細)を共有する方法を知りたいと思いました。それを行うコードを示しています..したがって、ユーザーが詳細を共有したい場合は、作成者のUIButtonすべてのセルにあるをタップする必要がありUITableViewます。

didselectatindexpath

    NSDictionary *selectedAuthor = nil;

     NSArray *sectionArray=[mainIndexDictionary objectForKey:[allKeysArray objectAtIndex:indexPath.section]];
        selectedAuthor = [sectionArray objectAtIndex:indexPath.row];
        iPath=[[selectedAuthor objectForKey:@"SymptIndexID"] intValue];
        NSLog(@"iPath - %d",iPath);

        authortitleString=[[selectedAuthor objectForKey:@"authorIndexName"]stringByAppendingString:@" cure!"];
    }


    bookArray=[objDB customCellData:(NSInteger)iPath];
    [self.view bringSubviewToFront:authorView];
    [bookTableView scrollRectToVisible:CGRectMake(0.0, 0.0, 320.0,10.0) animated:NO];

    [bookTableView reloadData]

;
4

2 に答える 2

10

iOS 6.0では、次のように実現できます(プロジェクトにソーシャルフレームワークを追加する必要があります)

 #import <Social/Social.h>

 - (void)ShareFacebook
 {
    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.....");
               // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

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


    [fbController setInitialText:@"This is My Sample Text"];


    [fbController setCompletionHandler:completionHandler];
    [self presentViewController:fbController animated:YES completion:nil];
}
else{
    UIAlertView *alert = [[[UIAlertView alloc]initWithTitle:@"Sign in!" message:@"Please first Sign In!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil]autorelease];
    [alert show];
 }
}
于 2013-03-22T19:09:29.670 に答える
1

あなたの質問は少し不明確ですが、FB ios Apiの他のすべてのメソッドを正しく実装していることを考慮して、このコードを使用してテキストと画像をFbに公開できます

SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       APP_NAME,@"text", fb_app_url,@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               APP_NAME, @"name",
                               fb_app_url, @"link",
                               fb_publish_image, @"picture",
                               APP_NAME, @"name",
                               @"Awesome APP", @"caption",
                               [NSString stringWithFormat:@"I am  loving it", GAME_NAME], @"description",
                               @"Get it now!",  @"message",
                               actionLinksStr, @"action_links",
                               nil];

[self.faceBook dialog:@"stream.publish" andParams:params andDelegate:self];

fb apiを実装するための詳細については、次を参照してください。

FacebookをiPhoneアプリに統合する方法ここにリンクの説明を入力してください

このリンクは、メッセージの公開中に許可されるパラメーターを示しています http://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/

于 2013-03-22T17:35:24.450 に答える