[英]I have FB friends images and names in custom table view. How to get selected row in FB ID's and send request to multiple friends?
我有單個FB ID,它不能進行多項選擇。我在FB好友列表中有自定義表格視圖。 如何獲取選定的行FB ID
NSMutableArray *arryOfFBIds;
for (id<FBGraphUser> user in self.friendPickerController.selection) {
NSMutableArray *selection=(NSMutableArray *) self.friendPickerController.selection;
[selection addObject:user.id];
arryOfFBIds = [[NSMutableArray alloc] init];
for (id<FBGraphUser> user in self.friendPickerController.selection)
{
[arryOfFBIds addObject:user.id ];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject: arryOfFBIds forKey: @"SelectedFBIds"];
[defaults synchronize];
NSLog(@"array of fb id:%@",arryOfFBIds);
}}
NSMutableDictionary* params2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Invite to on Ensmbl", @"description", @"http://placebogames.com/", @"link",
// 3. Suggest friends the user may want to request, could be game context specific?
[arryOfFBIds componentsJoinedByString:@","],@"to", nil];
NSLog(@"qwer:%@",params2);
[FBWebDialogs presentFeedDialogModallyWithSession:[FBSession activeSession] parameters:params2 handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
NSLog(@"error===>%@,resultURL===>%@",error,resultURL);
} ];
}
查看下載的SDK源文件(可能安裝在My Documents文件夾中) - 其中一個示例源代碼稱為FriendPickerSample.xcodeproj
簡而言之,為了顯示朋友的表格視圖,FB iOS使用一個名為FPViewController的特殊自定義tableview控制器類,它繼承自UIViewController但具有allowsMultipleSelection屬性,如果設置為TRUE,則允許您選擇幾個朋友,直到您按下完成按鈕。
完成按鈕將觸發一個名為的委托方法
- (void)facebookViewControllerDoneWasPressed:(id)sender {
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];
}
[self fillTextBoxAndDismiss:text.length > 0 ? text : @"<None>"];
}
只需使用示例代碼並進行修改,即可為所選朋友群做任何您想做的事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.