UINavigation:如何从呈现的模式视图推送视图
我在视图导航方面遇到问题。
我有 VC 说“登录”,我从另一个 VC 调用它,例如:
- (IBAction) btnAction
{ Login * login = [[Login alloc] init];
[self.navigationController pushViewController:login animated:YES];
}
在登录 VC 中,有两个按钮说“注册”和“忘记密码”,相应地调用另一个 VC、RegisterVC 和 ForgetPassVC。
- (IBAction) btnRegisterNow : (id) sender
{
aRegister = [[Register alloc] initWithNibName:@"Register" bundle:nil];
[self.navigationController pushViewController:aRegister animated:YES];
}
- (IBAction) btnForgotPassword : (id) sender
{
forgotPassword = [[ForgotPasswd alloc] initWithNibName:@"ForgotPasswd" bundle:nil];
[self.navigationController pushViewController:forgotPassword animated:YES];
}
我的问题:
当我通过 [self.navigationController PushViewController:loginanimated:YES]; 调用 Login 时,一切正常。
但在某些VC中我需要将登录页面显示为 [selfpresentModalViewController:loginanimated:YES];
此时注册和忘记密码两个按钮不起作用。单击按钮时没有任何反应。
问题是什么 ?我认为 bocz 我已将登录添加为模式视图而不是 PushViewConterller ???如果是这样那么我怎样才能完成这个任务?
希望问题很清楚。
谢谢...
I am having problem in navigation of views.
I have VC say, Login, which I am calling from another VC like :
- (IBAction) btnAction
{ Login * login = [[Login alloc] init];
[self.navigationController pushViewController:login animated:YES];
}
in login VC there are two buttons say, Register and Forget Password, that calls another VC, RegisterVC and ForgetPassVC accordingly.
- (IBAction) btnRegisterNow : (id) sender
{
aRegister = [[Register alloc] initWithNibName:@"Register" bundle:nil];
[self.navigationController pushViewController:aRegister animated:YES];
}
- (IBAction) btnForgotPassword : (id) sender
{
forgotPassword = [[ForgotPasswd alloc] initWithNibName:@"ForgotPasswd" bundle:nil];
[self.navigationController pushViewController:forgotPassword animated:YES];
}
My Problem :
When I call Login by [self.navigationController pushViewController:login animated:YES];
every thing works fine.
But in some VCs I need to display login page as [self presentModalViewController:login animated:YES];
At this time the two buttons, Register and Forget Password does not work. On button click nothing happens.
What is the problem ? I think bocz of I have added Login as modal view not a pushViewConterller ??? if so then how can I accomplish this task ?
hope question is clear.
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您以模态方式呈现控制器时,它们不在导航控制器中。你应该写
When you present your controller modally, they aren't in a navigation controller. You should write
我认为你应该按下“忘记密码”和“忘记密码”按钮。将 VC 也注册为模态控制器。你尝试过吗?
I think you should push the Forgot password & Register VCs also as modal controllers. Have you tried that?
当你在做的时候
[自我呈现ModalViewController:登录动画:是];在这种情况下,您的视图控制器将被传递,现在当您尝试实现 [self.navigationController PushViewController:forgotPasswordanimated:YES]; 时它不起作用,因为你没有导航控制器。
是否有必要将您的登录信息显示为模态视图。
然后使用此代码:-
现在您的忘记并注册 btn 操作将被调用,并将导航到相应的页面。
When you are doing
[self presentModalViewController:login animated:YES]; in this case your view controller get passed and now when you try to implement [self.navigationController pushViewController:forgotPassword animated:YES]; it did ont work because you dont have navigation controller.
Is it necessary to present your login as modal view.
Then use this code:-
Now your forgot and register btn action will called and will navigate to the that corresponding page.
当前导航控制器与您的登录视图控制器作为根控制器。检查下面的代码。
UINavigationController *navController = [UINavigationController alloc] initWithRootController:loginController];
[自我呈现ModalViewController:navController];
[navController发布];
Present navigation controller with your login view controller as root controller.Check below code.
UINavigationController *navController = [UINavigationController alloc] initWithRootController:loginController];
[self presentModalViewController:navController];
[navController release];