ios - 从另一个 View Controller 调用位于 Facebook sdk 上的函数

标签 ios facebook sdk viewcontroller

我在编程方面还很新,所以请不要让我太难过。我下载了 Facebook 的 Hackbook 版本。但是,我有许多将使用“共享此”按钮的 View Controller ,但我不知道该怎么做。我知道我想使用已经存在的功能。

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

谢谢。

最佳答案

看起来您只需要更改 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/iosdk/request/。和她的 [链接]http://developers.facebook.com/docs/reference/dialogs/有 7 个默认的一两行代码来共享东西

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

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

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

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

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

-Pay Dialog 允许用户使用 Facebook Credits 进行购买。

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

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

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

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

关于ios - 从另一个 View Controller 调用位于 Facebook sdk 上的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11597325/

相关文章:

ios - 即将到期的配置文件 - 企业部署

facebook - 如何使用 Swift 2.0 和 iOS 9.1 登录 Facebook?

ios - 登录 Facebook FBSDK 输入错误代码 : 308 in Swift 4. 2

java - 列出 Evernote 垃圾箱的内容

c# - SDK 路径在 Notepad++ plugin.net 中为空

ios - 为什么我不能在 Xcode 5 中将文件添加到 Images.xcassets?

ios - 如何使用 SwiftUI 处理屏幕触摸事件?

iphone - 除了使用 NSTimer 显示 AVAudioPlayer 音频文件的剩余时间之外,还有其他方法吗?

ios - 无法在 ios 中获取用户个人资料照片

c++ - 什么是适用于 Windows 7 和 .NET Framework 3.5 SP1 的 Microsoft Windows SDK?