【问题标题】:Can't get my detail view to show无法显示我的详细视图
【发布时间】:2009-07-05 21:25:14
【问题描述】:

我有一个带有四个选项卡的选项卡栏主窗口,其中一个是列表。这个列表一开始是空的,但是当我点击一个“+”时,我会看到一个可用选项的模式视图,像这样

- (IBAction)addThing:(id)sender {
    MJAvailableThingsViewController *controller = [self availableThingsViewController];
    [self presentModalViewController:availableThingsViewController animated:YES];
    [controller setEditing:YES animated:NO];
}

这行得通。

事物列表的每一行都有一个 UITableViewCellAccessoryDe​​tailDisclosureButton。这是通过accessoryTypeForRowWithIndexPath 完成的。这也有效。

当我单击此视图中的蓝色小按钮时,会调用委托附件按钮TappedForRowWithIndexPath。这行得通。

但是,在附件ButtonTappedForRowWithIndexPath 中,我想呈现该事物的详细视图,这就是我遇到问题的地方:

委托看起来像这样:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
{
    NSLog(@"accessoryButtonTappedForRowWithIndexPath");
    NSLog(@"Tapped row %d", [indexPath row]);

    [[self navigationController] pushViewController:thingDetailViewController animated:YES];

程序输入此代码但没有任何反应,即我得到 NSLog 输出但没有新窗口。我对此很陌生,所以如果这很明显,请原谅我;然而,对我来说,它不是...... :-)

【问题讨论】:

  • 你是如何初始化thingDetailViewController的
  • 我尝试重写 getter: - (ThingDetailViewController *)thingDetailViewController { // 如果需要,实例化添加视图控制器。 if (thingDetailViewController == nil) { thingDetailViewController = [ThingDetailViewController alloc]; } 返回的东西DetailViewController; }
  • 尝试:thingDetailViewController = [[ThingDetailViewController alloc] init];

标签: iphone


【解决方案1】:

你有navigationController吗?听起来您有TabController,但没有NavigationController

检查[self navigationController],是否设置为任何内容?

这里有一个类似的问题:
Tab Bar Application With Navigation Controller

【讨论】:

  • 不,我没有导航控制器。您指出的问题确实与我的问题非常相似,但我无法使用其中的建议,主要是由于无能为力。打扰。我最近的尝试为我呈现了一个视图,其中只有一个可用事物的表,而不是顶部带有标题栏的表和我以前拥有的添加按钮。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-04
相关资源
最近更新 更多