带有两个 NavigationController 链接协议的 splitViewController [英] splitViewController with Two NavigationController linking protocols

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

问题描述

添加源项目

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

我创建了一个基于拆分视图的应用程序.然后,我在 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 子类.我使用以下代码进行弹出:

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!

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

推荐答案

好的,我知道答案很晚,但我认为这个答案是完美且有效的.试试看.打开你的 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"

在@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.

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

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