简体   繁体   English

无法从委托方法中取消FBfriendPickerViewController

[英]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. 我正在使用Facebook FBFriendPickerViewController,希望用户只能选择一个朋友,然后关闭视图控制器。 In the FBFriendPickerDelegate, under the selectionDidChange method I am trying to capture what friend they selected and then dismiss the view controller. 在FBFriendPickerDelegate中,在selectionDidChange方法下,我试图捕获他们选择的朋友,然后关闭视图控制器。 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. 如果您以模态形式显示friendpicker控制器,则可以使用FBViewControllerDelegate协议的facebookViewControllerCancelWasPressed和facebookViewControllerDoneWasPressed方法将其关闭。 If you conform to FBFriendPickerDelegate you automatically conform to the first one. 如果您符合FBFriendPickerDelegate,则您将自动符合第一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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