Hide FBFriendPickerViewController navbar when clicking on UINavigationController

Presenting an instance of FBFriendPickerViewController using presentViewController:animated:completion: pretty simple, and the class seems to be designed for this use case. However, I want to push the FBFriendPickerViewController instance to the UINavigationController instance using pushViewController:animated:

As an example, consider the following code:

 self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init]; self.fbFriendPickerController.hidesBottomBarWhenPushed = YES; // configure stuff [[self navigationController] pushViewController:self.fbFriendPickerController animated:YES]; 

However, the problem is that the FBFriendPickerViewController instance already has a top navigation bar. When you click on the UINavigationController this causes the top two navigation panels to fold vertically, as shown in the screenshot below.

double top nav bars

One solution would be to hide the top navigation bar of the UINavigationController , but this creates an awkward transition and there is no return button. Any thoughts on how to save the top navigation bar of the UINavigationController but hide the top navigation bar of the FBFriendPickerViewController ?

+4
source share
1 answer

After viewing the IIS SDK on the iOS SDK on Github, I figured it out. FBFriendPickerViewController is a subclass of FBViewController . If you set the doneButton and cancelButton for any FBViewController to nil , the FBViewController will remove the top navigation bar. As a result, the following code works:

 self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init]; self.fbFriendPickerController.hidesBottomBarWhenPushed = YES; self.fbFriendPickerController.doneButton = nil; self.fbFriendPickerController.cancelButton = nil; // configure stuff [[self navigationController] pushViewController:self.fbFriendPickerController animated:YES]; 
+6
source

Source: https://habr.com/ru/post/1446602/


All Articles