在推送到UINavigationController时隐藏FBFriendPickerViewController导航栏 [英] Hide FBFriendPickerViewController navbar when pushing onto UINavigationController

查看:119
本文介绍了在推送到UINavigationController时隐藏FBFriendPickerViewController导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 presentViewController呈现 FBFriendPickerViewController 的实例:animated:completion:非常简单,类看起来像它用于该用例。但是,我想使用 pushViewController将 FBFriendPickerViewController 的实例推送到 UINavigationController 的实例上:动画:

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];

然而,问题是 FBFriendPickerViewController 已经有一个顶部导航栏。当按下 UINavigationController 时,会导致两个顶部导航栏垂直堆叠,如下面的屏幕截图所示。

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.

一种解决方案将隐藏 UINavigationController 的顶部导航栏,但这会产生一个尴尬的过渡,并且没有后退按钮。关于保持 UINavigationController 顶部导航栏的最佳方法的任何想法,但隐藏 FBFriendPickerViewController 顶部导航栏?

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?

推荐答案

浏览Facebook iOS SDK后源代码,我想出来了。 FBFriendPickerViewController FBViewController 的子类。如果设置任何 FBViewController的 doneButton cancelButton 属性 nil FBViewController 将删除顶部导航栏。因此,以下代码有效:

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];

这篇关于在推送到UINavigationController时隐藏FBFriendPickerViewController导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆