2013-03-21 9 views
5

私は、自分のアプリの詳細をFacebookに共有するためのアプリを提供しています。私はUITableviewに著者名のリストが含まれています。書籍名をクリックすると別のUITableViewに行きます。にその著者の別の本が表示されます。私は2番目にUITableViewのリストを表示することができます。 著者名、書籍名、画像(第2テーブルビューの詳細)をどのように共有するかを知りたかったのです。 これを行うコードを表示しています。 ユーザーが詳細を共有したいときは、UITableViewのすべてのセルにあるUIButtonをタップする必要があります。Facebookの壁にテキストと画像を共有する方法(目的C)

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] 

; 

答えて

10

を公開しながら、次のように達成することができ編(あなたのプロジェクトにsocial frameworkを追加する必要があります)

#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]; 
} 
} 
+0

http://www.techotopia.com/index.php/An_iPhone_iOS_6_Facebook_Integration_Tutorial_using_UIActivityViewController –

+0

私の現在の場所を投稿する方法?? –

1

あなたの質問は少し不明であるが、あなたは、あなたがへの更なる詳細については、FBのIOS APIを正しく

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に公開するテキストおよび画像のため、このコードを使用することができますこのリンクは、パラメータが許可を示し、あなたが

How to integrate Facebook into iPhone Appenter link description here

見ることができFBのAPIを実装IOSの6.0 でメッセージ http://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/

+0

私はIPATHから入手タイトル名を表示したいとiPath(書籍名、ジャンルなど)の詳細..詳細はSQL DBからフェッチされています。私はそれについてどうやって行くのか知りたかったのです – raptor

+0

アクションリンクの2番目の引数をiPathに置き換えます3番目の引数は画像あなたがホスティングしていない場合にあなたは静的な画像を(あなたはURLの中に置くことができます。 xcodeのプロジェクトに壁紙を貼り付ける必要があります。そこにはFacebook APIがあります。そこには画像データを投稿するためのいくつかの方法があります。 – hariszaman