編輯:添加源項目splitViewController配有兩張NavigationController連接協議
--> 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];
這是有效的。我遇到的問題是如何將信息或函數調用從Split View的Main一側傳遞到Split視圖的Detail一側?
如果通過以下方法呈現的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 <--
請關閉大寫鎖定。 – 2011-04-27 17:29:56