简体   繁体   English

UITableView单元格内的UIScrollView内的空白UITableView

[英]Blank UITableView inside UIScrollView inside a UITableView Cell

I am creating an App with following design: 我正在创建具有以下设计的应用程序:

I have a UITableView with custom UITableViewCell. 我有一个带有自定义UITableViewCell的UITableView。 Each UITableViewCell contains a scroll view with multiple UIViews of size 150x150 Each of the small UIView contains a UITableView. 每个UITableViewCell包含一个滚动视图,其中包含多个大小为150x150的UIViews。每个小UIView都包含一个UITableView。

Since i am new to this, the forum is not allowing me to upload a picture, which could have explained the design very easily. 由于我是新手,因此论坛不允许我上传图片,这可以很轻松地解释设计。

I have created the full design in the storyboard. 我已经在情节提要中创建了完整的设计。 The issue i am having is that the inner UITableView is not getting populated. 我遇到的问题是内部UITableView没有填充。 The cellForRowAtIndexPath , numberOfSections or the numberOfRowsInSection methods of the datasource table view controller class do not get called. 不会调用数据源表视图控制器类的cellForRowAtIndexPathnumberOfSectionsnumberOfRowsInSection方法。

I am using XCode 4.3.2 iOS5. 我正在使用XCode 4.3.2 iOS5。

Following are the class structure: 以下是类结构:

  • NewsTableViewController : The ViewController for the mail table. NewsTableViewController:邮件表的ViewController。
  • NewsTableViewCell : Custom TableViewCell which contains object of custom UIScrollView. NewsTableViewCell:自定义TableViewCell,其中包含自定义UIScrollView的对象。
  • NewsScrollView: Custom UIScrollView containing UIViews and UITableView objects which are linked to the Storyboard UITableViews inside the UIViews. NewsScrollView:包含UIViews和UITableView对象的自定义UIScrollView,这些对象链接到UIViews内部的Storyboard UITableViews。
  • NewsInnerTableViewController : TableViewController to be used as Datasource and Delegate for InnerTableViews. NewsInnerTableViewController:TableViewController用作InnerTableViews的数据源和委托。

I have created the object of NewsInnerTableViewController in NewsTableViewController and assigned it as delegate and datasource of the inner tableview. 我在NewsTableViewController中创建了NewsInnerTableViewController对象,并将其分配为内部tableview的委托和数据源。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSSTring *CellIdentifier = @"NewCell"
    NewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    newsInnerTableController = [[NewsInnerTableViewController alloc] initWithStyle:UITableViewStylePlain];

    cell.scrollView.innerTable.delegate = newsInnerTableController;
    cell.scrollView.innerTable.datasource = newsInnerTableController;

    return cell;
}

I am unable to understand where i am going wrong. 我无法理解我要去哪里。 or is something like this needs to be created is some other way. 还是需要创建这样的东西是其他方式。 or the Datasource and delegate needs to be assigned at some other level. 或需要在其他某个级别分配数据源和委托。

Please share your thoughts on this. 请分享您对此的想法。

the trick is to have the UITableTableViewCell as the Datasource and delegate for the inner UITableView 技巧是将UITableTableViewCell作为数据源并委托内部UITableView

http://iosstuff.wordpress.com/2011/06/29/adding-a-uitableview-inside-a-uitableviewcell/ http://iosstuff.wordpress.com/2011/06/29/adding-a-uitableview-inside-a-uitableviewcell/

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

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