1

我对编程很陌生,所以请不要把我烧得太厉害。我下载了 Facebook 的 Hackbook 版本。但是,我有许多视图控制器将使用“共享此”按钮,但我不知道该怎么做。我知道我想使用已经存在的功能。

@implementation ViewConcertsViewController
...

-(IBAction)shareThis:(id)sender{
[appDelegate.facebook authorize:nil delegate:self];
                APICallsViewController *apiViewController = [[APICallsViewController alloc] initWithNibName:nil bundle:nil];
                [apiViewController shareButton];
}

然后在我的 APICallsViewController 中,我有:

-(void)shareButton{
[self performSelector:@selector(//what do I put in here!!!!)];
}

先感谢您。

这就是我所做的:

@implementation ViewConcertsViewController
...
-(IBAction)shareThis:(id)sender{
    APICallsViewController *apiViewController = [[APICallsViewController alloc] initWithNibName:nil bundle:nil];
    [apiViewController shareButton:sender];
}


@implementation APICallsViewController
...
-(void)shareButton:(id)sender{
    SEL selector = NSSelectorFromString(@"getAppUsersFriendsNotUsing");
    if ([self respondsToSelector:selector]) {
        [self performSelector:selector];
    }
}

谢谢你。

4

1 回答 1

1

看起来您只需要在 APICallsViewController 中更改 Hackbook 示例中的方法。


/*
 * Dialog: Feed for friend
 */
- (void)apiDialogFeedFriend:(NSString *)friendID {
    currentAPICall = kDialogFeedFriend;
    SBJSON *jsonWriter = [[SBJSON new] autorelease];

    NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
                                                           @"Get Started",@"name",@"http://m.facebook.com/apps/hackbookios/",@"link", nil], nil];
    NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
    // The "to" parameter targets the post to a friend
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   friendID, @"to",
                                   @"I'm using the Hackbook for iOS app", @"name",
                                   @"Hackbook for iOS.", @"caption",
                                   @"Check out Hackbook for iOS to learn how you can make your iOS apps social using Facebook Platform.", @"description",
                                   @"http://m.facebook.com/apps/hackbookios/", @"link",
                                   @"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", @"picture",
                                   actionLinksStr, @"actions",
                                   nil];

    HackbookAppDelegate *delegate = (HackbookAppDelegate *)[[UIApplication sharedApplication] delegate];
    [[delegate facebook] dialog:@"feed"
                      andParams:params
                    andDelegate:self];

}

但是,如果您要发送 AppRequest(与 webpare 上的共享按钮不同),请结帐 - (void)apiDialogRequestsSendTarget:(NSString *)friend

那么你想分享什么?状态更新、照片、URL 链接、Facebook 应用请求。很多东西要分享,所以很难知道你想去哪里。[limk]http://developers.facebook.com/docs/reference/iossdk/request/。而她的 [link]http://developers.facebook.com/docs/reference/dialogs/ 有 7 个默认的一两行代码来分享东西

目前有 7 个对话框可供您使用:

** -Feed 对话框允许用户将故事发布到他们的时间轴和他们朋友的新闻源

- OAuth 对话框允许用户授权应用程序作为身份验证流程的一部分。

- 添加页面选项卡对话框允许用户将应用程序添加到他们管理的 Facebook 页面。

-好友对话框允许用户向另一个用户发送好友请求。

- 支付对话框允许用户使用 Facebook Credits 进行购买。

-请求对话框允许用户向他们的一个或多个朋友发送请求

- 发送对话框允许用户向他们的一个或多个朋友发送 Facebook 消息。**

但是,如果您可以提供任务的更多详细信息,它将更容易提供帮助和示例。对于我在 xcode 中设置应用程序项目以使用来自苹果和 Facebook 的自定义应用程序 ID 的 fb sdk 的经验来说,这是困难的部分。我强烈建议从头开始一个 Xcode 项目。这将花费更多时间,但是一旦您从开始设置应用程序到登录并通过 FBRequest 拥有朋友数据,您将能够非常快速地移动。

从一个示例应用程序开始,您将始终在后台运行您无法修复或改进或真正使用 API 的东西。

于 2012-07-22T07:23:08.663 回答