丢失导航控制器如何打开另一个视图 [英] Losing navigation controller how to open another view

查看:100
本文介绍了丢失导航控制器如何打开另一个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在显示如下的UIViewController:

I'm currently displaying a UIViewController like this:

AlaramDetail *alaramDetail = [[AlaramDetail alloc] init];
alaramDetail.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:alaramDetail animated:YES];
[alaramDetail release];

一切正常但我在AlarmDetail打开时丢失了导航控制器。我想从alarmDetail打开另一个视图我该怎么做。
如果我想要怎样才能返回我以前的导航控制器?
Thx

all works good but i lose the navigation controller when AlarmDetail opens. i want to open another view from alarmDetail how can i do so. and how can i return back to my previous navigation controller if i want ? Thx

推荐答案

您需要声明一个新的导航控制器,在其中添加您的视图控制器然后呈现模态导航控制器。

You need to declare an new navigation controller, add your view controller in it then present modal the navigation controller.

AlaramDetail *alaramDetail = [[AlaramDetail alloc] init];

UINavigationController *newNavigation = [[UINavigationController alloc] initWithRootViewController:alaramDetail];
[alaramDetail release];
newNavigation.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentModalViewController:newNavigation animated:YES];
[newNavigation release];

编辑:

要关闭模态视图:


  1. 简单方法:在你的模态视图中,你调用dismiss只是添加:

  1. Easy way: In your modal view in some method that you call to dismiss just add:

[self.navigationController dismissModalViewControllerAnimated:YES];

[self.navigationController dismissModalViewControllerAnimated:YES];

更复杂的方式:在模态视图上实现和委托协议并制作视图控制器,它呈现模态视图的委托。并且在委托方法中关闭模态视图。当我需要从模态视图向显示它的控制器发送数据时,我这样做。

More complex way: Implement and delegate protocol on your modal view and make the view controller that presents the modal view the delegate of it. And in the delegate method dismiss the modal view. I do this way when I need to send data from modal view to the controller that present it.

这篇关于丢失导航控制器如何打开另一个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆