-(void)checkLogin {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"LoginData" ofType:@"txt"];
NSString *myText = [NSString stringWithContentsOfFile:filePath];
//Parse lines into an NSArray;
NSArray *results= [myText componentsSeparatedByString:@"\n"];// Assumes Mac line end return
if([txtUsername.text isEqualToString: [results objectAtIndex:0]]&& [txtPassword.text isEqualToString: [results objectAtIndex:1]])
{
Clients * clients = [[Clients alloc] initWithNibName:@"clients" bundle:nil];
[self presentModalViewController:clients animated:YES];
}
else
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Login"
message:@"Wrong credentials"
delegate:nil
cancelButtonTitle:@"Close"
otherButtonTitles:nil];
[alert show];
}
}
@end
应用程序在此行崩溃
[self presentModalViewController:clients animated:YES];
非常感谢!
答案 0 :(得分:0)
Clients * clients = [[AboutUs alloc] initWithNibName:@"clients" bundle:nil];
[self presentModalViewController:clients animated:YES];
我认为第一行是您的应用卡住的地方。把它变成:
Clients * clients = [[Clients alloc] initWithNibName:@“clients”bundle:nil]; [self presentModalViewController:客户动画:是];
此代码应该有效,但在您的问题中,您在代码中添加了aboutUs
。
我不知道你想从这个问题做什么,但是如果你想把这个AboutUs
控制器放在你的Clients
控制器中,你应该使用类似的东西:
Clients *clients = [[Clients alloc] initWithRootViewController:aboutUs];
希望这可以帮助你
答案 1 :(得分:0)
您是否尝试过这样做:
Clients *myClients = [[Clients alloc] init];
[self presentViewController:clients animated:YES completion:^(void) {
}];
它应该正常工作。如果它仍然崩溃,那么Clients类中的某些内容就会出错。