gpt4 book ai didi

ios - UIViewController 实例问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:19 25 4
gpt4 key购买 nike

我正在尝试在单独的 swift 文件 (Login.swift) 上设置 NSUserDefaults 变量以确定我的用户是否已登录。如果用户确实已登录,则 LoginViewController 将消失并显示 HomeViewController。但是我被抛出这个错误

Use of instance member 'dismissViewControllerAnimated' on type 'UIViewController'; did you mean to use a value of type 'UIViewController' instead?

这是我的代码

//success
else if value["username"] != nil && value["password"] == nil && value["message"] == nil
{
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isUserLoggedIn")

LoginViewController.dismissViewControllerAnimated(true, completion:nil)

if let api_key = value["api_token"].string
{
print("The token is " + api_key)
}
else
{
print("error parsing api token")
}
//pass data to Users class
_ = Users.init(Name: value["name"].string, Email: value["email"].string, Id: value["id"].int, ProfilePicture: value["profile_picture"].string, Username: value["username"].string)
}

UIViewController error

最佳答案

创建LoginViewController 的对象。使用该对象然后调用 dismissViewControllerAnimated 函数。不允许从类名直接调用

关于ios - UIViewController 实例问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37202063/

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