FBFriendPickerViewController崩溃

时间:2012-07-18 23:35:23

标签: iphone ios xcode facebook

前几天我有这个工作,你登录到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 length]:无法识别的选择器发送到实例0xa9b7c70 2012-07-18 19:22:14.980 MeetUp [7213:1dc03] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSDictionaryI length]:无法识别的选择器发送到实例0xa9b7c70' * 第一次抛出调用堆栈: (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 0x358e7c 0x205d 0x1f85) libc ++ abi.dylib:terminate调用抛出异常

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

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

我猜错误是因为某些原因它在尝试加载配置文件图片时崩溃(SIGABRT)。如果有人知道为什么这会很棒,特别是看到它工作并在几天前加载图片。

1 个答案:

答案 0 :(得分:-1)

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

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

[FBGraphObjectTableDataSource tableView:imageForItem:]

Ergo设置:

self.friendPickerController.itemPicturesEnabled = NO;

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