2013-03-21 12 views
5

Tôi đang làm việc trên một ứng dụng cung cấp cho người dùng chia sẻ chi tiết về ứng dụng của họ vào facebook. Tôi có UITableview, nơi nó chứa danh sách tên tác giả và khi bạn nhấp vào tên sách, nó sẽ chuyển đến một tên khác là UITableView nơi nó hiển thị một cuốn sách khác của tác giả đó trong mỗi TableViewCell. Tôi có thể hiển thị danh sách ở số 02 UITableView. Tôi muốn biết cách chia sẻ tên tác giả, tên sách và hình ảnh (chi tiết lần xem thứ 2). Tôi đang hiển thị mã thực hiện điều đó .. Vì vậy, khi người dùng muốn chia sẻ chi tiết, anh ấy sẽ phải nhấn vào UIButton có trong mọi ô của tác giả UITableView.Cách chia sẻ văn bản và hình ảnh trên tường facebook (mục tiêu 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] 

; 

Trả lời

10

Trong ios 6.0 bạn có thể đạt được như sau (bạn phải thêm social framework để dự án của bạn)

#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

đi qua liên kết http://www.techotopia.com/index.php/An_iPhone_iOS_6_Facebook_Integration_Tutorial_using_UIActivityViewController –

+0

làm thế nào tôi có thể đăng vị trí hiện tại của tôi ?? –

1

câu hỏi của bạn là một chút không rõ ràng nhưng bạn có thể sử dụng mã này cho văn bản xuất bản và hình ảnh để fb xem xét bạn đã thực hiện tất cả các phương pháp khác của FB ios Api đúng

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]; 

để biết thêm chi tiết để thực hiện fb api bạn có thể thấy

How to integrate Facebook into iPhone Appenter link description here

liên kết này cho thấy các thông số cho phép ed khi xuất bản một thông điệp http://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/

+0

Tôi muốn hiển thị tên tiêu đề mà tôi nhận được từ iPath và chi tiết của iPath (tên sách, thể loại vv) .. các chi tiết được lấy từ db sql .. tôi muốn biết làm thế nào để đi về nó – raptor

+0

chỉ cần thay thế arg thứ 2 trong actionlinks với iPath arg thứ 3 là cho hình ảnh có thể được lấy thông qua một URL (bạn có thể đặt tất cả các hình ảnh trong Url và truy cập chúng thông qua XML) nếu bạn không có bất kỳ lưu trữ nào và bạn muốn đăng hình ảnh tĩnh bên trong xcode dự án tường bạn phải xem api Facebook có một số phương pháp có cho phép dữ liệu hình ảnh được đăng – hariszaman