I'm a beginner in iOS programming, so please don't kill me :]。 I have application with authorization and when I successful authorize I would like go to second view。 When authorization fails I show alert。 My code for the authorization:
- (IBAction)LoginClick:(id)sender { for(User *user in self.allUsers){ if([user.userName isEqualToString:self.usernameTextField.text] && [user.password isEqualToString:self.passwordTextField.text]){ // Logged in --> go to second view (TableView) [self performSegueWithIdentifier:@"LoginSegue" sender:self]; } else{ // Wrong password or username Alerts *alert = [Alerts new]; [alert showAlert:LOGIN_ERROR]; } } }
澳门百家乐玩法大全I tried to look a simple way for custom transition (segue) to second view, when I successful log in, but I didn't find。 Now I have this storyboard:
And code for transition between View is:
[self performSegueWithIdentifier:@"LoginSegue" sender:self];
The result is error:
* Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'LoginSegue'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
What is the problem? Why I need something like "Navigation controller". I need to create a class for segue? What is the simplest way to solve this problem? Thank you.
澳门百家乐玩法大全EDIT ------- SOLUTION
Thanks to all for help. I added navigation controller to my application as initial view. And I found, that use of a custom segue and making class for this custom segue is unnecessary. The simplest way for solution my problem is connect the ViewControllers (NOT BUTTON and second ViewController, so I had it first time...) and name the push segue. The name I used here in code:
- (IBAction)LoginClick:(id)sender { for(User *user in self.allUsers){ if([user.userName isEqualToString:self.usernameTextField.text] && [user.password isEqualToString:self.passwordTextField.text]){ // Logged in --> go to second view (TableView) [self performSegueWithIdentifier:@"LoginSegue" sender:self]; } else{ // Wrong password or username Alerts *alert = [Alerts new]; [alert showAlert:LOGIN_ERROR]; } } }
Concrete here: [self performSegueWithIdentifier:@"LoginSegue" sender:self];
And all works great。 When I login with correctly pass and username I'm redirected to second View。
The error is telling you you can't use that type of transition without using a navigation controller。
Simply drag and drop a navigation controller from the right menu and set it as the Initial Controller in the properties section on the right. like so:
Then connect your login controller as its root view controller。 Then this will work for you。
The end result should look something like:
我在的iOS编程初学者,所以请不要杀我:]。我有授权的,当我成功的授权,我想转到第二个视图的应用程序。当授权失败我显示警告。我的code的授权:
- (IBAction为)LoginClick:(ID)发送{ 对(在self.allUsers用户*用户){
如果([user.userName isEqualToString:self.usernameTextField.text]放大器;&安培; user.password的isEqualToString:self.passwordTextField.text]){
//已登录 - >到第二个视图(TableView中)
[个体经营performSegueWithIdentifier:@LoginSegue”发件人:个体经营];
}
其他{
// 用户名或密码错误
快讯*警报= [快讯新]
[警报showAlert:LOGIN_ERROR];
}
}
}
我想看看一个简单的方法进行自定义转换(SEGUE),以第二种观点,当我成功登录,但我没有找到。现在,我有这样的情节提要:
的
和code为浏览之间的过渡是:
[自performSegueWithIdentifier:@LoginSegue”发件人:个体经营];
结果是错误:
的*终止应用程序由于未捕获的异常'NSGenericException,理由是:”找不到赛格瑞导航控制器LoginSegue”。推时,源控制器由UINavigationController的一个实例管理塞格斯只能用'强>
这是什么问题?为什么我需要的东西,如导航器”。我需要创建一个赛格瑞类?什么是解决这一问题最简单的方法?谢谢你。
编辑------- SOLUTION
感谢所有的帮助。我添加导航控制器到我作为初始视图的应用程序。而且我发现,这个定制赛格瑞使用自定义SEGUE与制作类是不必要的。最简单的方法解决了我的问题是连接ViewControllers(NOT BUTTON和第二的ViewController,所以我有它第一次...),并命名为推动SEGUE。这个名字我以前在这里code:
- (IBAction为)LoginClick:(ID)发送{ 对(在self.allUsers用户*用户){
如果([user.userName isEqualToString:self.usernameTextField.text]放大器;&安培; user.password的isEqualToString:self.passwordTextField.text]){
//已登录 - >到第二个视图(TableView中)
[个体经营performSegueWithIdentifier:@LoginSegue”发件人:个体经营];
}
其他{
// 用户名或密码错误
快讯*警报= [快讯新]
[警报showAlert:LOGIN_ERROR];
}
}
}
混凝土进入:[自performSegueWithIdentifier:@LoginSegue”发件人:个体经营];
和所有伟大工程。当我登录正确传递和用户名,我重定向到第二个视图。
该错误是告诉你,你不能使用这种类型的转型不使用导航控制器。
只需拖动并从右键菜单中删除一个导航控制器,并将其设置在右边的属性部分的初始控制器。像这样:
那么你的登录控制器连接为根视图控制器。那么这会为你工作。
最终的结果应该是这个样子:
本文地址:IT屋 » 成功登录后自定义SEGUE
我在的iOS编程初学者,所以请不要杀我:]。我有授权的,当我成功的授权,我想转到第二个视图的应用程序。当授权失败我显示警告。我的code的授权:
- (IBAction为)LoginClick:(ID)发送{ 对(在self.allUsers用户*用户){
如果([user.userName isEqualToString:self.usernameTextField.text]放大器;&安培; user.password的isEqualToString:self.passwordTextField.text]){
//已登录 - >到第二个视图(TableView中)
[个体经营performSegueWithIdentifier:@“LoginSegue”发件人:个体经营];
}
其他{
// 用户名或密码错误
快讯*警报= [快讯新]
[警报showAlert:LOGIN_ERROR];
}
}
}
我想看看一个简单的方法进行自定义转换(SEGUE),以第二种观点,当我成功登录,但我没有找到。现在,我有这样的情节提要:
的
和code为浏览之间的过渡是:
[自performSegueWithIdentifier:@“LoginSegue”发件人:个体经营];
结果是错误:
的*终止应用程序由于未捕获的异常'NSGenericException“,理由是:”找不到赛格瑞导航控制器“LoginSegue”。推时,源控制器由UINavigationController的一个实例管理塞格斯只能用'强>
这是什么问题?为什么我需要的东西,如“导航器”。我需要创建一个赛格瑞类?什么是解决这一问题最简单的方法?谢谢你。
编辑------- SOLUTION
感谢所有的帮助。我添加导航控制器到我作为初始视图的应用程序。而且我发现,这个定制赛格瑞使用自定义SEGUE与制作类是不必要的。最简单的方法解决了我的问题是连接ViewControllers(NOT BUTTON和第二的ViewController,所以我有它第一次...),并命名为推动SEGUE。这个名字我以前在这里code:
- (IBAction为)LoginClick:(ID)发送{ 对(在self.allUsers用户*用户){
如果([user.userName isEqualToString:self.usernameTextField.text]放大器;&安培; user.password的isEqualToString:self.passwordTextField.text]){
//已登录 - >到第二个视图(TableView中)
[个体经营performSegueWithIdentifier:@“LoginSegue”发件人:个体经营];
}
其他{
// 用户名或密码错误
快讯*警报= [快讯新]
[警报showAlert:LOGIN_ERROR];
}
}
}
混凝土进入:[自performSegueWithIdentifier:@“LoginSegue”发件人:个体经营];
和所有伟大工程。当我登录正确传递和用户名,我重定向到第二个视图。
该错误是告诉你,你不能使用这种类型的转型不使用导航控制器。
只需拖动并从右键菜单中删除一个导航控制器,并将其设置在右边的属性部分的初始控制器。像这样:
那么你的登录控制器连接为根视图控制器。那么这会为你工作。
最终的结果应该是这个样子:
本文地址:IT屋 » 成功登录后自定义SEGUE
I'm a beginner in iOS programming, so please don't kill me :]。 I have application with authorization and when I successful authorize I would like go to second view。 When authorization fails I show alert。 My code for the authorization:
- (IBAction)LoginClick:(id)sender { for(User *user in self.allUsers){ if([user.userName isEqualToString:self.usernameTextField.text] && [user.password isEqualToString:self.passwordTextField.text]){ // Logged in --> go to second view (TableView) [self performSegueWithIdentifier:@"LoginSegue" sender:self]; } else{ // Wrong password or username Alerts *alert = [Alerts new]; [alert showAlert:LOGIN_ERROR]; } } }
I tried to look a simple way for custom transition (segue) to second view, when I successful log in, but I didn't find。 Now I have this storyboard:
And code for transition between View is:
[self performSegueWithIdentifier:@"LoginSegue" sender:self];
The result is error:
* Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'LoginSegue'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
What is the problem? Why I need something like "Navigation controller". I need to create a class for segue? What is the simplest way to solve this problem? Thank you.
EDIT ------- SOLUTION
Thanks to all for help。 I added navigation controller to my application as initial view。 And I found, that use of a custom segue and making class for this custom segue is unnecessary。 The simplest way for solution my problem is connect the ViewControllers (NOT BUTTON and second ViewController, so I had it first time。。。) and name the push segue。 The name I used here in code:
- (IBAction)LoginClick:(id)sender { for(User *user in self.allUsers){ if([user.userName isEqualToString:self.usernameTextField.text] && [user.password isEqualToString:self.passwordTextField.text]){ // Logged in --> go to second view (TableView) [self performSegueWithIdentifier:@"LoginSegue" sender:self]; } else{ // Wrong password or username Alerts *alert = [Alerts new]; [alert showAlert:LOGIN_ERROR]; } } }
Concrete here: [self performSegueWithIdentifier:@"LoginSegue" sender:self];
And all works great。 When I login with correctly pass and username I'm redirected to second View。
The error is telling you you can't use that type of transition without using a navigation controller.
Simply drag and drop a navigation controller from the right menu and set it as the Initial Controller in the properties section on the right. like so:
Then connect your login controller as its root view controller. Then this will work for you.
The end result should look something like:
