gpt4 book ai didi

session - FBFriendPickerViewController 间歇性地加载一个空的 tableview

转载 作者:行者123 更新时间:2023-12-04 05:12:20 25 4
gpt4 key购买 nike

我正在使用 FBFriendPickerViewController 在用户登录后加载 friend 。但是,正在加载一个空表 View 。来自 fb 的用户的 friend 没有出现。
这是代码。

- (IBAction)inviteButtonTouchHandler:(id)sender {
if (!_friendPickerController) {
_friendPickerController = [[FBFriendPickerViewController alloc] initWithNibName:nil bundle:nil];
_friendPickerController.delegate = self;
_friendPickerController.title = @"Select friends";
_friendPickerController.allowsMultipleSelection = NO;
}
[_friendPickerController clearSelection];
[_friendPickerController loadData];
[self presentViewController:_friendPickerController animated:YES completion:nil];
}

登录后调用此代码,按照 Facebook 教程在 appDelegate 中执行此操作 -
- (void)openSession
{
NSArray *permissions = @[@"friends_about_me"];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}

最佳答案

您需要在 viewController 的 viewDidLoad 方法中添加以下代码。

if (!FBSession.activeSession.isOpen) {
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession.activeSession openWithCompletionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
switch (state) {
case FBSessionStateClosedLoginFailed:
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
break;
default:
break;
}
}];
}

关于session - FBFriendPickerViewController 间歇性地加载一个空的 tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14757817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com