【发布时间】:2012-10-25 11:15:42
【问题描述】:
我正在关注 Getting Started with the Facebook SDK for iOS v3.1 以使用 Storyboard 将 Facebook SDK 添加到我的 xCode 项目中。
我完成了那里描述的所有步骤。
我们在 Facebook SDK 的 Sample 文件夹中有一个 HelloFacebookSample。它包含以下代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Create Login View so that the app will be granted "status_update" permission.
FBLoginView *loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
}
// Post Status Update button handler; will attempt to invoke the native
// share dialog and, if that's unavailable, will post directly
- (IBAction)postStatusUpdateClick:(UIButton *)sender {
// Post a status update to the user's feed via the Graph API, and display an alert view
// with the results or an error.
NSString *name = self.loggedInUser.first_name;
NSString *message = [NSString stringWithFormat:@"Updating status for %@ at %@",
name != nil ? name : @"me" , [NSDate date]];
// if it is available to us, we will post using the native dialog
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self
initialText:nil
image:nil
url:nil
handler:nil];
if (!displayedNativeDialog) {
[self performPublishAction:^{
// otherwise fall back on a request for permissions and a direct post
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
self.buttonPostStatus.enabled = YES;
}];
self.buttonPostStatus.enabled = NO;
}];
}
}
然后示例工作正常,但是当我想在自己的项目中使用它时,我遇到了这个问题:
已成功将 FBLoginView 添加到我的 self.view。但是当我Login 然后想发布一些东西时,我就去这个页面:
【问题讨论】:
-
您是否在设置应用中配置了任何 iOS6 Facebook 帐户?通常,当没有配置帐户时,您会在 iOS 6 上收到此消息。
-
我想在模拟器上测试一下。不是设备。我怎样才能做到这一点?正如我所说的那样,样本对我有用,那么为什么它有效而我自己的无效呢?
-
即使在模拟器中也可以设置并在 facebook 中添加帐户,以便您可以发布
-
没有用。问题应该出在其他地方。它应该是在我自己的带有故事板的项目中添加 Facebook SDK。
-
你添加了框架#import
标签: iphone objective-c ios xcode facebook