简体   繁体   English

无法将tableview添加到uiview

[英]Failing to add tableview to uiview

I'm dynamically creating uiviews which contain uitableviews (uiviews are tableview and datasource delegates for their respective tables. The uiviews are created using a xib file). 我正在动态创建包含uitableviews的uiviews(uiviews是它们各自表的tableview和数据源委托。uiviews是使用xib文件创建的)。 When I reach the numberOfRowsInSection function and try to return [self.mydata count], mydata is empty. 当我到达numberOfRowsInSection函数并尝试返回[self.mydata count]时,mydata为空。

  1. When I break at the numberOfRowsInSection function I've noticed each uiview does not have the same address as any of the uiviews I previously created. 当我在numberOfRowsInSection函数处中断时,我注意到每个uiview的地址都与我之前创建的uiview的地址不同。
  2. I've noticed my numberOfRowsInSection function is called after all the views are created and added to my viewcontroller. 我注意到在创建所有视图并将其添加到我的viewcontroller之后,将调用我的numberOfRowsInSection函数。
    1. numberOfRowsInSection is called multiple times, but is not equal to the number of uiviews I have created. numberOfRowsInSection被多次调用,但不等于我创建的uiview的数量。

Any thoughts? 有什么想法吗?

I figured out my issue. 我知道了我的问题。 I was setting the uitableviewdelegate and uitableviewdatasource to the uiview in the xib file, when in fact I want the File's Owner (which is the specific uiview created at runtime). 我实际上在需要文件的所有者(这是在运行时创建的特定uiview)时,将uitableviewdelegate和uitableviewdatasource设置为xib文件中的uiview。

I simply clicked and dragged (in the xib file) from the delegate and datasource outlets to the File's Owner placeholder button thing. 我只是单击并从委托和数据源出口(在xib文件中)拖到“文件的所有者”占位符按钮处。

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

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