【发布时间】:2014-06-29 15:13:40
【问题描述】:
我正在开发一个 iOS 应用程序,但在测试过程中遇到了一个问题:当我尝试进入下一个 ViewController 时应用程序崩溃并收到以下消息:
2014-06-29 14:22:46.674 IOS2 Practica[55472:60b] -[Logger login:]: unrecognized selector sent to instance 0x9242230
2014-06-29 14:22:46.679 IOS2 Practica[55472:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Logger login:]: unrecognized selector sent to instance 0x9242230'
从我查过的其他案例来看,当我尝试使用“segue”切换到下一个 ViewController 但我无法确定确切的来源时,可能会发生某些事情。
我在我的主视图控制器中附加了定义 segue 的代码段:
- (void)logger:(id)sender {
NSString *user = self.username.text;
NSString *pass = self.password.text;
NSString * urlBase = @"http://www.v2msoft.com/clientes/lasalle/curs-ios/login.php?username=lluis&password=seguro";
[JSONHTTPClient getJSONFromURLWithString:urlBase completion:^(id json,JSONModelError *err){
JsonUser * user = [[JsonUser alloc]initWithDictionary:json error:nil];
if(user.succeed) {
self.user_id = user.user_id;
[self performSegueWithIdentifier:@"Login" sender:self];
} else {
NSLog(@"error");
}
}];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if (_username.text.length == 0 || _password.text.length == 0) {
[[[UIAlertView alloc] initWithTitle:@"Error"
message:@"Algun dels camps és incorrecte o està buit!"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil, nil]
show];
} else {
Supermarket * supermercat = segue.destinationViewController;
supermercat.user_id = self.user_id;
}
}
提前感谢您对此主题的任何见解。
【问题讨论】:
-
你是否在故事板中设置了标识符为“Login”的segue?
-
是的。我检查的第一件事。我有segues,我确实检查了名称是否匹配。所以不是这样。感谢您的建议。
标签: ios segue unrecognized-selector