我正在关注Apple示例代码“MultipleDetailViews”,但我想要做的是:
因此,在RootViewController.m中,我推送另一个导航 ...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SubCatVC *browseSubCatView = [[SubCatVC alloc] initWithNibName:@"SubCatVC" bundle:nil];
[self.navigationController pushViewController:browseSubCatView animated:YES];
[browseSubCatView release];
}
然后,在SubCatVC.m
中- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController <SubstitutableDetailViewController> *detailViewController = nil;
SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailViewController" bundle:nil];
detailViewController = newDetailViewController;
// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
self.splitViewController.viewControllers = viewControllers;
[viewControllers release];
// Dismiss the popover if it's present.
if (self.popoverController != nil) {
[self.popoverController dismissPopoverAnimated:YES];
}
// Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).
if (self.rootPopoverButtonItem != nil) {
[detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}
[detailViewController release];
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateProduct" object:nil];
}
但它没有更新我的detailView ..所以我不知道什么是错的? Src在这里:http://pastebin.com/iy6SqLqt
希望有人可以告诉我。感谢
答案 0 :(得分:0)
我没有查看您的来源,但是分割视图的常见问题是委托。
当您在导航堆栈上推送新的rootController时,您需要确保它具有指向您希望与之通信的detailViewController的指针。在尝试更新代理之前,您可以检查htis我的日志记录:
在您的SubCatVC(或任何根)中:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//do stuff, init alloc vc's....
NSLog(@"DELEGATE: %@",self.delegate);
//push/delegate etc..
}
如果你发现它的nil,复制原始的root委托,或者当你把新的细节放入时,请通知/设置你想要与它通信的根。
如果您需要更多细节,请询问。