Ich versuche, von der Anmeldung zum View Menu Controller (id Storyboard: Menü) übergeben.Ändern Sie die Ansicht von Aufgabe zu anderen swift
Um View Controller schalte ich einen Übergang in den Login-Button haben, wird Login mit Login.swift verbunden.
In Login.swift, indem Sie auf die Schaltfläche Login klicken geschieht Folgendes:
Request().login(tag, email: email, pass: pass)
In Antrag habe ich dies:
class Request {
func login(tag : String, email : String, pass : String){
let url = NSURL(string: "xxx");
let request = NSMutableURLRequest(URL:url!)
request.HTTPMethod = "POST";
let postString = "tag="+tag+"&email="+email+"&password="+pass;
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding);
let session = NSURLSession.sharedSession();
let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
let json = JSON(data: data!)
Login().passPostData(json)
});
task.resume();
}}
In Anmeldung passPostData:
func passPostData(json: JSON){
let total = json.count
for i in 0..<total{
let id = json[i]["id"].string!
let username = json[i]["username"].string!
let birthday = json[i]["birthday"].string!
let location = json[i]["location"].string!
let email = json[i]["email"].string!
let photo = json[i]["photo"].string!
print(id + " - " + username + " - " + birthday + " - " + location + " - " + email + " - " + photo)
}
SwiftLoading().hideLoading()
//self.performSegueWithIdentifier("goToMenu", sender: self)
//let menuController = self.storyboard?.instantiateViewControllerWithIdentifier("menu") as? ViewMenuController
//self.navigationController?.pushViewController(menuController!, animated: true)
//let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil);
//let vc : UIViewController = storyboard.instantiateViewControllerWithIdentifier("menu") as UIViewController;
//self.presentViewController(vc, animated: true, completion: nil);
}
kommentiert Linien sind alle Wege, die ich versucht habe, zum View Menu Controller zu gehen.
Beim Versuch, mit:
self.performSegueWithIdentifier("goToMenu", sender: self)
bekomme ich diesen Fehler:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<xxx.Login: 0x7f9d28545000>) has no segue with identifier 'goToMenu''
Aber die segue zwischen Anmeldung und Menü Ansicht Controller ist die Kennung goToMenu zugeordnet
Wenn mit dem Versuch, :
let menuController = self.storyboard?.instantiateViewControllerWithIdentifier("menu") as? ViewMenuController
self.navigationController?.pushViewController(menuController!, animated: true)
Nicht funktioniert oder schlägt fehl.
Beim Versuch, mit:
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil);
let vc : UIViewController = storyboard.instantiateViewControllerWithIdentifier("menu") as UIViewController;
self.presentViewController(vc, animated: true, completion: nil);
ich diesen Fehler:
Warning: Attempt to present <xxx.ViewMenuController: 0x7f9139ef46e0> on <xxx.Login: 0x7f9139d871c0> whose view is not in the window hierarchy!
Wie kann ich es tun?
zwei Dinge vergessen Sie hier –
Sie benötigen 'ViewController' mit' UINavugationController' einzubetten. –