iPad:带导航的 SplitViewController

发布于 2024-10-07 18:45:06 字数 2068 浏览 0 评论 0原文

我正在遵循Apple示例代码“MultipleDetailViews”,但我想做的是:

  1. 在开始时,显示RootViewController(表视图),
  2. 当用户选择表单元格时显示默认的detailViewController(第一个detailView),推入堆栈,显示splitView 的 master 中的 SubCategoriesVC (表视图),但不更新明细视图。
  3. 在 SubCategoriesVC 中,选择一个表格单元格..更新detailViewController(第二个detailView)

因此,在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];
}

,但它没有更新我的详细视图..所以我不知道出了什么问题? 源代码在这里:http://pastebin.com/iy6SqLqt

希望有人能给我建议。谢谢

I'm following Apple sample code "MultipleDetailViews" but what I want to do is that:

  1. at start, shows the RootViewController (table view) display the default detailViewController (1st detailView)
  2. when user selected a table cell, push into the stack, display the SubCategoriesVC (table view) in the master of the splitView but don't update the detailView.
  3. in SubCategoriesVC, selecting a table cell.. update the detailViewController (2nd detailView)

So, in RootViewController.m, I push another navigation
...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    SubCatVC *browseSubCatView = [[SubCatVC alloc] initWithNibName:@"SubCatVC" bundle:nil];
    [self.navigationController pushViewController:browseSubCatView animated:YES];
    [browseSubCatView release];
}

Then, in 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];
}

but it didn't update my detailView.. so I don't know what's wrong?
Src here: http://pastebin.com/iy6SqLqt

Hope someone can advise me. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七色彩虹 2024-10-14 18:45:06

我没有看过你的来源,但是分割视图的一个常见问题是委托。

当您将新的 rootController 推到导航堆栈上时,您需要确保它具有指向您希望其与之通信的detailViewController 的指针。在尝试更新委托之前,您可以检查我记录的委托:

在您的 SubCatVC(或任何与此相关的根)中:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

//do stuff, init alloc vc's....

NSLog(@"DELEGATE: %@",self.delegate);

//push/delegate etc..

}

如果您发现其为零,请复制原始根委托,或者当您放入新详细信息时,通知/设置您想要与之通信的根。

如果您需要更多详细信息,请询问。

I Have not looked at your source, but but a common problem with Split views are delegates.

When you Push a new rootController ont the nav stack, you need to make sure it has the pointer to the detailViewController that you want it to talk to. You can check htis my logging the delegate before you try to update it:

In your SubCatVC (or any root for that matter):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

//do stuff, init alloc vc's....

NSLog(@"DELEGATE: %@",self.delegate);

//push/delegate etc..

}

If you find its nil, copy the original roots delegate, or when your putting your new detail in, notify/set the root you want to comunicate with it.

If you need any more detail, just ask.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文