Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone didSelectRowAtIndexPath不推送新视图控制器,也没有错误_Iphone - Fatal编程技术网

Iphone didSelectRowAtIndexPath不推送新视图控制器,也没有错误

Iphone didSelectRowAtIndexPath不推送新视图控制器,也没有错误,iphone,Iphone,我有个新问题。我有一个表视图控制器,乍一看工作正常。它会打印我的Nsmutabledictionary中的所有行。当我单击一行时,它会按预期启动此函数,而不会崩溃或出现系统错误: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"

我有个新问题。我有一个表视图控制器,乍一看工作正常。它会打印我的Nsmutabledictionary中的所有行。当我单击一行时,它会按预期启动此函数,而不会崩溃或出现系统错误:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

    SCInventoryLeaf *childView = [storyboard instantiateViewControllerWithIdentifier:@"inventoryleaf"];

    NSArray *keys = [arrInventory allKeys];
    id aKey = [keys objectAtIndex:indexPath.row];
    id anObject = [arrInventory objectForKey:aKey];
    childView.title = aKey;
    childView.price = [anObject objectForKey:@"price"];

    [self.navigationController pushViewController:childView animated:YES];
}
但是由于某种原因,我的儿童视图在点击后没有显示出来。我在情节提要中正确地命名了标识符

有什么不对劲吗?下一步我该去哪里


编辑——我还应该提到我在SCInventoryLeaf.m的viewDidLoad中放置了一些断点,但它们似乎从未被解雇。所以我猜SCInventoryLeaf.m从未使用过?但我很确定我的tblviewcontroller和scinventoryleaf之间存在一种关系….

输入一个断点,然后检查
childView
是否不等于
nil
。如果是,请再次检查“inventoryleaf”的大小写是否正确。你拼写它“InventoryLeaf”了吗?如果需要,从情节提要中剪切并粘贴。

您的其余代码看起来很好。

我确信这是一个非常新的疏忽,因为我知道我以前做过这项工作。提出了非常好的问题,提供了很好的信息,并且在提问之前进行了很好的自我调试。旁注:如果您使用的是故事板,您只需使用模式序列将原型单元连接到SCInventoryLeaf,即可自动获得显示视图。您可以在
prepareforsgue:
中进行初始配置。您根本不需要实现
didSelectRowAtIndexPath
。您确定执行过上述方法吗?在pushViewController的前面添加一个childView的NSLog,以确保到达该位置,并确保childView不为零。(你可能还想记录self.navigationController,只是为了露齿而笑。)“我还应该提到,我在SCInventoryLeaf.m的viewDidLoad中设置了一些断点,但它们似乎从未被炒鱿鱼。”这确实说明了问题(而且很有帮助),我同意@stevekohis的观点。尝试放置断点并单步通过
didSelectRowAtIndexPath
,使用变量窗格查看结果。我打赌
childView
为零,因为标识符
inventoryLeaf
在情节提要中的大小写与代码中的大小写不同,因此它们不匹配。