J.D*_*Doe 5 model-view-controller xcode ios segue swift
所以我在两个视图控制器之间执行segue时遇到了问题.
我们打电话给2个视图控制器
答:LoginViewController
B:ViewController
在BI中有一个"Log Out"按钮(它是一个左栏按钮项),当它点击它时触发一个函数,就像这样,并调用dismissViewController并返回A.
@IBAction func logOutButton(sender: AnyObject) {
let actionController = UIAlertController(title: "Log out", message: "Are you sure you want to log out?", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default){UIAlertAction in
self.prefs.setInteger(0, forKey: "ISLOGGEDIN")
self.prefs.setInteger(0, forKey: "PERMISSIONTOLOADDATA")
self.prefs.synchronize()
print("User logged out")
socket.disconnect()
self.dismissViewControllerAnimated(true, completion: nil)
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default){UIAlertAction in
print("Test: Log out action cancelled")
}
actionController.addAction(okAction)
actionController.addAction(cancelAction)
self.presentViewController(actionController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
这里没有错,但是当我在A的文本字段中输入我的ID并单击Login按钮时,它会触发这样的错误:
2016-02-02 17:33:12.879 iCare[3852:190330] <UIView: 0x7facd153cfd0; frame = (0 0; 375 667); alpha = 0.95; autoresize = W+H; tintColor = UIDeviceRGBColorSpace 1 1 1 1; layer = <CALayer: 0x7facd153d140>>'s window is not equal to <UINavigationController: 0x7facd187ae00>'s view's window!
Run Code Online (Sandbox Code Playgroud)
登录按钮的代码:
@IBAction func LoginButton(sender: AnyObject) {
let logInUserID = loginPatientID.text
let logInUserIDUpper = logInUserID?.uppercaseString
if (logInUserIDUpper!.isEmpty){
displayAlertMessage("Please enter your Patient ID!")
return
}else{
print("Test: requesting login permission from database")
loginSocket.emit("loginRequest", logInUserIDUpper!)
print("Test: requested")
loginSocket.on("loginReply") {data, ack in
let jsonLogin = JSON(data)
if jsonLogin[0].intValue == 1{
print("Test: ID Matched, putting up ViewController")
self.prefs.setObject(logInUserIDUpper, forKey: "AppUserID")
self.prefs.setInteger(1, forKey: "ISLOGGEDIN")
self.prefs.synchronize()
loginSocket.disconnect()
self.loginPatientID.resignFirstResponder()
self.performSegueWithIdentifier("gotoVC", sender: self)
}else if jsonLogin[0].intValue == 0{
self.displayAlertMessage("Sorry, you are not assigned to this program")
}else if jsonLogin[0].intValue == 3{
self.displayAlertMessage("Internet is not stable, please try again later")
print("Test: Query problem")
}else{
print("Test: not getting anything from ID database")
}
}//socket.on
}//else
}//login button
Run Code Online (Sandbox Code Playgroud)
我提到了这个
并认为我的问题与Paka先生不同,因为我的注销按钮没有执行segue而是解雇了视图控制器本身,这反过来可能导致重叠.
有什么建议?
| 归档时间: |
|
| 查看次数: |
2020 次 |
| 最近记录: |