【问题标题】:splitViewController with Two NavigationController linking protocols带有两个 NavigationController 链接协议的 splitViewController
【发布时间】:2011-03-10 17:04:12
【问题描述】:

编辑:添加源项目

--> I uploaded a sample project that clearly shows my dilemma which can be found here <--

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

然后,当单击工具栏项时,我会弹出一个新的 UIViewController 子类。我使用以下代码进行弹出:

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

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

如果我通过以下方法呈现 UIViewController:

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;

我能够按预期通过协议完成回访。

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

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>

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

--> I uploaded a sample project that clearly shows my dilemma which can be found here <--

【问题讨论】:

    标签: iphone uinavigationcontroller uisplitviewcontroller ipad


    【解决方案1】:

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

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

    在@interface RootViewController 中写下这一行

    Left *lefty;
    Right *righty;
    

    之后将属性声明为,

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

    去ROOTVIEWCONTROLLER.M文件合成为,

    @synthesize lefty;
    @synthesize righty;
    

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

        - (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写这个,

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

    完成,运行您的应用程序。我测试了,完成了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2012-05-17
      • 1970-01-01
      相关资源
      最近更新 更多