splitViewController与两个NavigationController链接协议 [英] splitViewController with Two NavigationController linking protocols

查看:85
本文介绍了splitViewController与两个NavigationController链接协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:已添加源项目

- >我上传了一个示例项目,清楚地显示了我的困境,可以在这里找到< -

我创建了一个拆分视图基于应用程序。然后我在MainWindow.xib中的DetailViewController中添加了第二个UINavigationController。

I created a Split View-based Application. I then added a second UINavigationController to the DetailViewController inside the MainWindow.xib.

然后在单击工具栏项时弹出一个新的UIViewController子类。我使用以下代码来执行pop:

I then pop a new UIViewController Subclasses when a toolbar item is clicked. I use the following code to conduct the pop:

DocumentDetailVC *DetailViewController = [[DocumentDetailVC alloc] initWithNibName:@"DocumentDetailVC" bundle:[NSBundle mainBundle]];
[detailViewController.detailNavController pushViewController:DetailViewController animated:YES];

DocumentsVC *RRequestViewController = [[DocumentsVC alloc] initWithNibName:@"DocumentsVC" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:RRequestViewController animated:YES];

这是有效的。我遇到的问题是如何将信息或函数调用从拆分视图的主侧传递到拆分视图的详细信息侧?

This works. The issue I am having is how do I pass information or function calls from the Main side of the Split View to the Detail side of the Split view?

如果我提供UIViewController通过以下方法:

If I present the UIViewController via the following method:

DocumentDetailVC *RRequestViewController = [[DocumentDetailVC alloc] initWithNibName:@"DocumentDetailVC" bundle:[NSBundle mainBundle]];
RRequestViewController.delegate=self;
RRequestViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[RRequestViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:RRequestViewController animated:YES];
[RRequestViewController release];
RRequestViewController = nil;

我可以按预期通过协议完成回程。

I am able to complete a reach back through a protocol as intended.

DocumentDetailVC,当通过pushViewController加载时,层次结构如下:

DocumentDetailVC, when loaded via the pushViewController, the hierarchy is as follows:

NSLog([NSString stringWithFormat:@"%@",self]); 
//self = <DocumentDetailVC: 0x4e0d960>
NSLog([NSString stringWithFormat:@"%@",self.parentViewController]);
//self.parentViewController = <UINavigationController: 0x4e0ce30>
NSLog([NSString stringWithFormat:@"%@",self.parentViewController.parentViewController]);
//self.parentViewController.parentViewController = <UISplitViewController: 0x4e0d0f0>

感谢您的协助。这个问题正在消耗我的生命!

Thank you for your assistance. This problem is consuming my life!

- > I上传了一个示例项目,清楚地显示了我在这里可以找到的困境< -

推荐答案

好的,我知道答案很晚,但我认为这个答案是完美和有效的。尝试一下。打开你的RootViewController.h,在顶部写下这一行:

Ok, I know am very late for answer but this answer is, I think, perfect and working. Try it. Open your RootViewController.h, on the top write this line:

#import "Left.h"
#import "Right.h"

in @interface RootViewController写这行

in @interface RootViewController write this lines

Left *lefty;
Right *righty;

在声明属性后,

@property (nonatomic, retain) Left *lefty;
@property (nonatomic, retain) Right *righty;

转到ROOTVIEWCONTROLLER.M文件综合为,

go to ROOTVIEWCONTROLLER.M file synthesize as,

@synthesize lefty;
@synthesize righty;

之后在RootViewController.m中用这个替换你的函数

after that in RootViewController.m just replace your function with this one

    - (IBAction)myBtnPushed{
    NSLog(@"myBtnPushed");


    lefty = [[Left alloc] initWithNibName:@"Left" bundle:[NSBundle mainBundle]];
    righty = [[Right alloc] initWithNibName:@"Right" bundle:[NSBundle mainBundle]];

    lefty.delegate=righty;
    [self.navigationController pushViewController:lefty animated:YES];

    [detailViewController.navigationController pushViewController:righty animated:YES];


}

在delloac中写这个,

in delloac write this,

[lefty release];
lefty = nil;
[righty release];
righty = nil;

完成后,运行你的应用程序。我测试过,已经完成了。

It's done, run your app. I tested, it's done.

这篇关于splitViewController与两个NavigationController链接协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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