简体   繁体   中英

Can't dismiss FBfriendPickerViewController from delegate method

I am using the facebook FBFriendPickerViewController and want the user to only be able to select one friend and then have it dismiss the view controller. In the FBFriendPickerDelegate, under the selectionDidChange method I am trying to capture what friend they selected and then dismiss the view controller. I can't get it to dismiss, I feel like I have done this type of thing many times before so I feel kind of dumb asking this, but I feel like I have exhausted every variation of this and nothing works.

-(void)friendPickerViewControllerSelectionDidChange:(FBFriendPickerViewController *)friendPicker{
    self.selectedFriends = friendPicker.selection;
    NSLog(@"%@", self.selectedFriends);
    [friendPicker dismissViewControllerAnimated:YES completion:nil];
}

I have also tried

[[friendPicker parentViewController] dismissViewControllerAnimated:YES completion:nil];

[self.friendPickerController dismissViewControllerAnimated:YES completion:nil];

[self.navigationController dismissViewControllerAnimated:YES completion:nil];

[[friendPicker navigationController] dismissViewControllerAnimated:YES completion:nil];

[self dismissViewControllerAnimated:YES completion:nil];

all to no avail.

由于您可能已将其推送为导航Viewcontroller,因此需要将其弹出:

[self.navigationController popViewControllerAnimated:YES];

If you present the friendpicker controller modally you can dismiss it by using the facebookViewControllerCancelWasPressed and the facebookViewControllerDoneWasPressed methods of the FBViewControllerDelegate protocol. If you conform to FBFriendPickerDelegate you automatically conform to the first one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM