ios - Facebook SDK:UINavigationController 没有成员“推送”
问题描述
我正在使用 Facebook 的 SDK 允许用户使用 Facebook 登录我的应用程序。登录按钮完美运行。它允许用户登录和退出并找到正确的配置文件。但是,当用户登录时,我需要应用程序显示不同的视图控制器,代码如下:
override func viewDidLoad()
{
super.viewDidLoad()
var loginButton = FBLoginButton(permissions: [ .publicProfile ])
let screenSize:CGRect = UIScreen.main.bounds
let screenHeight = screenSize.height // real screen height
//let's suppose we want to have 10 points bottom margin
let newCenterY = screenHeight - loginButton.frame.height - 20
let newCenter = CGPoint(x: view.center.x, y: newCenterY)
loginButton.center = newCenter
view.addSubview(loginButton)
if(AccessToken.current != nil) {
let storyboard = UIStoryboard(name: "Logged In", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "Logged In")
self.navigationController?.push(vc, animated: true) // this is the error line
}
// Extend the code sample "1. Add Facebook Login Button Code"
// In your viewDidLoad method:
loginButton = FBLoginButton(permissions: [ .publicProfile, .email, .userFriends ])
}
这是错误消息:“UINavigationController”类型的值没有成员“推送”
我正在使用最新的 SDK 版本。所以不知道怎么回事?
解决方案
你必须使用self.navigationController?.pushViewController(VC, animated: true)
而不是push
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Logged In") as NextViewController
self.navigationController?.pushViewController(VC, animated: true)
推荐阅读
- eclipse - 我可以在创建 Xtext 项目后将 eclipse-plugin 添加到它吗?
- android - Android 与 AsyncTask
- laravel - Laravel实现css下拉菜单不起作用
- sql-server - 访问除事务 SQL Server 中的记录之外的剩余记录
- javascript - 当文本字段值更改时,Magento 显示/隐藏渲染按钮
- c# - 在 winform 或 WPF 中使用“toast 通知”
- vba - VBA - 隐藏行宏限制
- lua - Lua table.insert 不起作用
- amazon-web-services - Terraform:如何从一个资源块创建多个 aws 子网?
- node.js - 无法使用 Firebase Cloud Functions 创建 xlsx 文件