Hide FBFriendPickerViewController navbar when pushing onto UINavigationController

facebook-ios-sdk, ios, objective-c

Solution

After looking through the Facebook iOS SDK source code on Github, I figured this out. `FBFriendPickerViewController` is a subclass of `FBViewController`. If you set the `doneButton` and `cancelButton` properties of any `FBViewController` to `nil`, `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];

Problem

Presenting an instance of `FBFriendPickerViewController` using `presentViewController:animated:completion:` is pretty straightforward and the class seems like it is meant for that use case. However, I want to push an instance of `FBFriendPickerViewController` onto an instance of `UINavigationController` using `pushViewController:animated:`. Consider the following code as an example: ``` self.fbFriendPickerController = [[FBFriendPickerViewController alloc] init]; self.fbFriendPickerController.hidesBottomBarWhenPushed = YES; // configure stuff [[self navigationController] pushViewController:self.fbFriendPickerController animated:YES]; ``` However, the problem is that the instance of `FBFriendPickerViewController` already has a top navigation bar. When pushed onto a `UINavigationController`, this results in two top navigation bars stacked vertically, as you can see in the screenshot below. One solution would be to hide the top nav bar of the `UINavigationController`, but that creates an awkward transition and there is no back button. Any thoughts on the best way to keep the `UINavigationController` top nav bar but the hide the `FBFriendPickerViewController` top nav bar?

Original source