UINavigation:如何从呈现的模式视图推送视图

发布于 2024-12-01 04:20:30 字数 1132 浏览 1 评论 0原文

我在视图导航方面遇到问题。

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

紫﹏色ふ单纯 2024-12-08 04:20:30

当您以模态方式呈现控制器时,它们不在导航控制器中。你应该写

UINavigationViewController *nvc = [[UINavigationViewController alloc] initWithRootViewController:login];
[login release];
[self presentModalViewController:nvc animated:YES];
[nvc release];

When you present your controller modally, they aren't in a navigation controller. You should write

UINavigationViewController *nvc = [[UINavigationViewController alloc] initWithRootViewController:login];
[login release];
[self presentModalViewController:nvc animated:YES];
[nvc release];
原野 2024-12-08 04:20:30

我认为你应该按下“忘记密码”和“忘记密码”按钮。将 VC 也注册为模态控制器。你尝试过吗?

I think you should push the Forgot password & Register VCs also as modal controllers. Have you tried that?

蹲在坟头点根烟 2024-12-08 04:20:30

当你在做的时候
[自我呈现ModalViewController:登录动画:是];在这种情况下,您的视图控制器将被传递,现在当您尝试实现 [self.navigationController PushViewController:forgotPasswordanimated:YES]; 时它不起作用,因为你没有导航控制器。

是否有必要将您的登录信息显示为模态视图。
然后使用此代码:-

 - (IBAction) btnAction 
{
        Login *login=[[[Login alloc]initWithNibName:@"Login" bundle:nil]autorelease];
        UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:login]autorelease];
        [[self navigationController] presentModalViewController:navController animated: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:-

 - (IBAction) btnAction 
{
        Login *login=[[[Login alloc]initWithNibName:@"Login" bundle:nil]autorelease];
        UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:login]autorelease];
        [[self navigationController] presentModalViewController:navController animated:YES];

    }   

Now your forgot and register btn action will called and will navigate to the that corresponding page.

凉城 2024-12-08 04:20:30

当前导航控制器与您的登录视图控制器作为根控制器。检查下面的代码。

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];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文