加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 如何在Facebook墙上分享文字和图像(目标C)

发布时间:2020-12-14 19:30:10 所属栏目:百科 来源:网络整理
导读:我正在开发一个应用程序,用户可以将他们的应用程序的详细信息分享到Facebook.我有UITableview,它包含作者姓名列表,当你点击书名时,它会转到另一个UITableView,在那里它显示每个TableViewCell中该作者的不同书.我能够在第二个UITableView中显示列表. 我想知道
我正在开发一个应用程序,用户可以将他们的应用程序的详细信息分享到Facebook.我有UITableview,它包含作者姓名列表,当你点击书名时,它会转到另一个UITableView,在那里它显示每个TableViewCell中该作者的不同书.我能够在第二个UITableView中显示列表.
我想知道如何分享作者姓名,书名和图像(第2张表格详情).
我正在展示那样做的代码..
因此,当用户想要分享细节时,他将不得不点击作者UITableView的每个单元格中的UIButton.

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]

;

解决方法

在ios 6.0中
你可以实现如下(你必须将 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];
 }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读