0

我正在IOS上开发Facebook SDK3.0,我使用developers.facebook.com生成了Facebook密钥

my App ID/API Key 
165158463618789

登录工作正常,但在使用FBFriendPickerViewController它时会崩溃,

我使用了以下代码:

   FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc]     init];
   self.friendPickerController = friendPicker;

   [friendPicker loadData];
   friendPicker.navigationItem.title = @"Pick Friends";
   friendPicker.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] 
                                                  initWithTitle:@"Done" 
                                                  style:UIBarButtonItemStyleBordered 
                                                  target:self 
                                                                 action:@selector(doneButtonWasPressed:)];
    friendPicker.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] 
                                                 initWithTitle:@"Cancel" 
                                                 style:UIBarButtonItemStyleBordered 
                                                 target:self 
                                                 action:@selector(cancelButtonWasPressed:)];
 [self.navigationController pushViewController:friendPicker animated:YES];

我得到崩溃的原因

-[__NSCFDictionary 长度]:无法识别的选择器发送到实例 0x3024d0 2012-08-07 11:13:12.430 IndusPatient[784:707] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[__NSCFDictionary 长度]:无法识别的选择器sent to instance 0x3024d0' * First throw call stack: (0x321a888f 0x341fe259 0x321aba9b 0x321aa915 0x32105650 0x320f1f19 0x3210e2cd 0x3210d1ad 0x3210e279 0x37a73fb1 0x37a73e8b 0x1a9735 0x1a9bbf 0x31c2fefb 0x31c2efd9 0x31c2e763 0x31bd2f37 0x321071fb 0x33e6baa5 0x33e6b6bd 0x33e6f843 0x33e6f57f 0x33e674b9 0x3217cb1b 0x3217ad57
0x3217b0b1 0x320fe4a5 0x320fe36d 0x31255439 0x31bfdcd5 0xcdd2b 0xcdccc) terminate called throwing an exception

4

1 回答 1

0

i was also facing this problem but now i have resolved it.

using following method/code, i resolved issue

In AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Add this line

[FBFriendPickerViewController class];

In your viewController header file add

@property (retain, nonatomic) FBFriendPickerViewController *friendPickerController;

In your viewController implementation file add in a function

if (self.friendPickerController == nil) {
    // Create friend picker, and get data loaded into it.
    self.friendPickerController = [[FBFriendPickerViewController alloc] init];
    self.friendPickerController.title = @"Pick Friends";
    self.friendPickerController.delegate = self;
}

[self.friendPickerController loadData];
[self.friendPickerController clearSelection];

[self presentModalViewController:self.friendPickerController animated:YES];

so i have not used navigation controller style programming.

于 2012-09-04T06:04:52.547 回答