ios - 登录页面未完全注销用户 iOS

标签 ios swift authentication xcode7 alamofire

所以我有一个登录页面,其中一个 View Controller 中有两个 View 。其中一个 View 是登录页面,另一个 View 显示用户信息。它们通过登录和注销按钮链接。 一旦它登录到页面,它就可以正常工作。问题是当我注销时它会返回到登录页面。但是当我尝试在不关闭模拟器的情况下使用另一个用户登录时,之前的用户信息仍然存在。不知道是我的代码问题还是我设置的问题。页面是这样设置的

更新:似乎在手机停止并重新启动之前,旧的 json 文件根本不会被清除。执行此操作后,将显示最后登录的用户。所以下载部分有问题。我发送了正确的用户名和密码,但它从不更新用户页面中的用户界面。

这是正在使用的大部分代码

//userNameInput:  passwordInput:

@IBAction func onLoginClick(sender: AnyObject) {
    myUserNAmeInput = TextFieldInput1.text!
    myPasswordUserInput = TextInput2.text!

    checkLoginCredentials(url)

}

@IBAction func onLogoutClick(sender: AnyObject) {
    //null out everything for logout
    theuserName = ""
    theUserPass = ""
     self.myJson = ""

    self.stored.setObject(self.userNAme, forKey: "uName")
    self.stored.setObject(self.userpassword, forKey: "uPass")
    self.stored.synchronize()
    self.view = myView
}

    func downlaodCI(myUrl : String, myUser : String, myPass : String)
    {
    Alamofire.request(.GET, myUrl)
        .authenticate(user: myUser, password: myPass)
        .validate(statusCode: 200..<300)
        .responseString { response in
            //print("Success: \(response.result.isSuccess)")
            print("Response String: \(response.result.value)")
            self.myJson = response.result.value!


    }
}

感谢您对此的任何帮助

最佳答案

您需要清除每个字段的所有信息,如下所示:

userNameInput.text = ""
passwordInput.text = ""

关于ios - 登录页面未完全注销用户 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37245512/

相关文章:

swift - 一起使用 CocoaPods 和 @IBDesignable

ios - 在 Xcode 中创建并附加一个 .txt 文件到电子邮件

iOS swift : Pushing two view controllers when app launched from push notification

ios - 添加 viewForAnnotation 时注释标题不出现

javascript - 使用 jQuery 进行 CORS 身份验证

php - 使用带有 Angular JS 的 mySQL 数据库的用户登录系统?

ios - 室内导航如何使用 iBeacon 在 iOS 中工作?

iphone - NSString 或 UILabel 带有反斜杠穿过字母

ios - 我在游戏中使用计时器,想显示当前分数并保存最高分。我该怎么做?

java - 如何向运行 solr 的 Jetty Web 服务器添加自定义身份验证