我在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 length]:无法识别的选择器发送到实例0x3024d0 2012-08-07 11:13:12.430 IndusPatient [784:707] *由于未捕获的异常'NSInvalidArgumentException'而终止应用, 原因:' - [__ NSCFDictionary长度]:无法识别的选择器发送到 instance 0x3024d0'* 第一次抛出调用堆栈: (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) 终止调用抛出异常
答案 0 :(得分:0)
我也遇到了这个问题,但现在我已经解决了。
在AppDelegate中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
添加此行
[FBFriendPickerViewController class];
在viewController头文件中添加
@property (retain, nonatomic) FBFriendPickerViewController *friendPickerController;
在viewController实现文件中添加一个函数
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];
所以我没有使用导航控制器样式编程。