【发布时间】:2009-07-05 21:25:14
【问题描述】:
我有一个带有四个选项卡的选项卡栏主窗口,其中一个是列表。这个列表一开始是空的,但是当我点击一个“+”时,我会看到一个可用选项的模式视图,像这样
- (IBAction)addThing:(id)sender {
MJAvailableThingsViewController *controller = [self availableThingsViewController];
[self presentModalViewController:availableThingsViewController animated:YES];
[controller setEditing:YES animated:NO];
}
这行得通。
事物列表的每一行都有一个 UITableViewCellAccessoryDetailDisclosureButton。这是通过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