It gives:
signal SIGABRT
Another error in log says:
libc++abi.dylib: terminating with uncaught exception of type NSException
@IBAction func loginok(sender: AnyObject) {
if loginTextField?.text != "monal" && passwordTextField?.text != "gosai"
{
warningLable?.text = "Invalid Credentials"
loginTextField?.text = ""
passwordTextField?.text=""
}
else
{
let View2 = self.storyboard!.instantiateViewControllerWithIdentifier("View2") as! ViewController2
self.navigationController!.pushViewController(View2, animated: true)
}
}
PerformSegueWithIdentifier
won't work unless you've set up a segue in the storyboard. If you have, then in your else
statement as Francisco stated you should call that function. If you have not set up the segue on the Storyboard then you will have to do so to use this method.
Also, as a matter of convention, your @IBAction
method header should read func loginok(sender: UIButton) {...}
您需要为segue设置一个标识符,然后使用
self.performSegueWithIdentifier("YourIdentifier", sender: self)
In the storyboard click on the segue and in Utilities->Attributes inspector->Identifier type a name , I used "mySegue" Below the Identifier, for Segue , make it Modal.
create a button and ctrl drag to the m file: This is my code:
- (IBAction)nAction:(UIButton *)sender {
self.mytext = self.mytextfield.text;
[self performSegueWithIdentifier:@"mySegue" sender:sender];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"mySegue"])
{
NSLog(@" my segues is called mysegue");
myViewController *controller = [segue destinationViewController] ;
controller.textforlabel = self.mytext;
}
Don't forget to include the h file where you define the destination viewcontroller for the segue :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.