gpt4 book ai didi

ios - Facebook SDK : UINavigationController has no member 'push'

转载 作者:行者123 更新时间:2023-12-01 17:46:19 27 4
gpt4 key购买 nike

我正在使用 Facebook 的 SDK 允许用户使用 Facebook 登录我的应用程序。登录按钮完美运行。它允许用户登录和退出并找到正确的配置文件。但是,当用户登录时,我需要应用程序显示不同的 View Controller ,代码如下:

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)

关于ios - Facebook SDK : UINavigationController has no member 'push' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59823019/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com