简体   繁体   English

在详细视图中显示为表视图创建的数据

[英]Displaying data created for a table view in a detail view

(First post here ... new to iOS.) (第一篇文章... iOS的新手。)

In my xTableViewController in the the didSelectRowAtIndexPath method I am setting the value of data to be displayed in a detail view for the row: 在我的xTableViewController的didSelectRowAtIndexPath方法中,我设置要在该行的详细信息视图中显示的数据的值:

[xDetailViewController setDetailLabel:[xDetailTextArray objectAtIndex:row]]; 

In my xDetailViewController.xib I have an sub view for detailLabel and the IBOutlet is declared as an ivar and property in xDetailViewController.h and synthesized in xDetailViewController.m. 在我的xDetailViewController.xib中,我有一个detailLabel的子视图,并且IBOutlet在xDetailViewController.h中声明为ivar和属性,并在xDetailViewController.m中进行了合成。 My confusion here is how to get the value for detailLabel, created in the xTableViewController, to display in the detail view label sub view. 我的困惑是如何获取在xTableViewController中创建的detailLabel的值,以显示在详细视图标签子视图中。 I know that the detailLabel is hooked up correctly in the XIB because in the xDetailViewController viewWillAppear method I can have the detailLabel display a value when the table row is selected by using: 我知道detailLabel在XIB中已正确连接,因为在xDetailViewController viewWillAppear方法中,当使用以下方法选择表行时,可以让detailLabel显示一个值:

detailLabel.text = @"test detail text";

... but I am lost as to how to get detailLabel.text to display the value of the row from xDetailTextArray created in the xTableViewController. ...但是我迷失了如何从xTableViewController中创建的xDetailTextArray获取detailLabel.text来显示行的值。 By stepping through the debugger I see that detailLabel contains the correct data value from the array for the row I selected. 通过逐步调试器,我看到detailLabel包含了数组中我所选行的正确数据值。

I guess I conceptually don't get that if I have set the value for detailLabel.text as in the first snippet and I can see the data value for it in the debugger, why doesn't the data value "just appear" in the outlet when the detail view is pushed for display? 我想从概念上讲,如果我像在第一个代码段中那样设置了detailLabel.text的值,并且在调试器中可以看到它的数据值,为什么数据值不会“仅出现”在调试器中按下详细视图进行显示时如何打开插座? And since it is not, what do I code, I assume, in the xDetailViewController to display the data? 而且由于不是,我假设在xDetailViewController中编码什么以显示数据?

Any warnings? 有警告吗? try 尝试
self.xDetailViewController.detailLabel.text = [xDetailTextArray objectAtIndex:row];
maybe you can't call the setFunction 也许你不能调用setFunction

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM