2

几天前,我进行了这项工作,在您登录 facebook 后,您可以单击一个按钮,然后 FBFriendPickerViewController 将出现一个包含所有 facebook 朋友的列表。然而,突然间它开始因一些奇怪的错误而崩溃。这是我的代码:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [FBSession.activeSession handleOpenURL:url];
}

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
// attempt to extract a token from the url
return [FBSession.activeSession handleOpenURL:url];
}

在我家 viewcontroller.m

// Pick Friends button handler
- (IBAction)pickFriendsClick:(UIButton *)sender {
// Create friend picker, and get data loaded into it.
FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
self.friendPickerController = friendPicker;

[friendPicker loadData];

// Create navigation controller related UI for the friend picker.
friendPicker.navigationItem.title = @"Pick Friends";

friendPicker.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
                                                  initWithTitle:@"Done"
                                                  style:UIBarButtonItemStyleBordered
                                                  target:self
                                                  action:@selector(friendPickerDoneButtonWasPressed:)];
friendPicker.navigationItem.hidesBackButton = YES;

// Make current.
[self.navigationController pushViewController:friendPicker animated:YES];
}


// Handler for when friend picker is dismissed
- (void)friendPickerDoneButtonWasPressed:(id)sender {

[self.navigationController popViewControllerAnimated:YES];

NSString *message;

if (self.friendPickerController.selection.count == 0) {
    message = @"<No Friends Selected>";
} else {

    NSMutableString *text = [[NSMutableString alloc] init];

    // we pick up the users from the selection, and create a string that we use to update the text view
    // at the bottom of the display; note that self.selection is a property inherited from our base class
    for (id<FBGraphUser> user in self.friendPickerController.selection) {
        if ([text length]) {
            [text appendString:@", "];
        }
        [text appendString:user.name];
    }
    message = text;
}

[[[UIAlertView alloc] initWithTitle:@"You Picked:"
                            message:message
                           delegate:nil
                  cancelButtonTitle:@"OK"
                  otherButtonTitles:nil]
 show];
}

最后,这是我在点击设置为 pickFriendsClick 方法的按钮时收到的错误消息:

2012-07-18 19:22:14.978 MeetUp[7213:1dc03]-[__NSDictionaryI 长度]:无法识别的选择器发送到实例 0xa9b7c70 2012-07-18 19:22:14.980 MeetUp[7213:1dc03] * 由于未捕获而终止应用程序exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0xa9b7c70' * First throw call stack: (0x1f626a2 0x13ede7e 0x1feda3d 0x1f522bc 0x1f5204e 0x1edd7d0 0x1ef5c98 0x1fcff7b 0x1ef5b42 0xde4d5a 0xe3ace8 0xe3ac93 0x20138 0x20718 0x410ffb 0x4110cf 0x3f9e1d 0x40a4db 0x3a79ba 0x14016be 0x25a53a6 0x259973c 0x2599550 0x2517690 0x25187fb 0x2518eb6 0x1f2b27e 0x1f2b1bd 0x1f08f22 0x1f086a4 0x1f0857b 0x1a7a913 0x1a7a798 0x358e17c 0x358e17c 0x205d 异常终止)

同样,我实现的登录和注销功能运行良好,不久前还运行良好,但现在它给我带来了麻烦。任何帮助将不胜感激。谢谢!

编辑:好的,所以我添加了这行代码:[friendPicker setItemPicturesEnabled:NO]; 现在它可以工作了,但显然我没有在 tableview 单元格中得到小缩略图。

我猜错误是它在尝试加载个人资料图片时由于某种原因崩溃(SIGABRT)。如果有人知道为什么会这样,那就太好了,尤其是在几天前看到它工作并加载了图片时。

4

1 回答 1

-1

当我遇到相同的问题和 tldr 并错过了黑客解决方案时,要将您的内容添加到答案中。

堆栈跟踪显示在一行中抛出了一个异常:

[FBGraphObjectTableDataSource tableView:imageForItem:]

人体工学设置:

self.friendPickerController.itemPicturesEnabled = NO;

似乎解决了这个问题,因为它不会加载图像。

于 2012-07-27T05:06:29.513 回答