0

我用facebook's AsyncDisplayKit 来运行我的项目,在那里我找到了一个名为“ ASDKgram ”的示例项目。它使用节点而不是 TableViewCells。默认情况下,' AsTableNodes' aka TableView 显示在屏幕的边界。

我希望从 uiScreen 的每个边缘显示我的tableView或。AsTableNodes10pixels

问题:如何使用该特定框架创建 AsTableNodes?

如果有人已经通过了AsyncDisplayKit,请回复。

这是该项目的链接https://github.com/facebook/AsyncDisplayKit/tree/master/examples/ASDKgram

提前致谢。

4

1 回答 1

1

使用 ASCollectionNode

一、更换

tableNode = [[ASTableNode alloc] init];

tableNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]];

然后将其添加到 ASViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  _tableNode.view.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
}

- (ASSizeRange)collectionView:(ASCollectionView *)collectionView constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath {
  return ASSizeRangeMake(
          CGSizeMake(0, 0),
          CGSizeMake(self.view.frame.size.width - 2*10, CGFLOAT_MAX)
  );
}

- (NSInteger)collectionNode:(ASCollectionNode *)collectionNode numberOfItemsInSection:(NSInteger)section {
  return [_photoFeed numberOfItemsInFeed];
}

- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath {
  PhotoModel *photoModel = [_photoFeed objectAtIndex:indexPath.row];
  // this will be executed on a background thread - important to make sure it's thread safe
  ASCellNode *(^ASCellNodeBlock)() = ^ASCellNode *() {
      PhotoCellNode *cellNode = [[PhotoCellNode alloc] initWithPhotoObject:photoModel];
      return cellNode;
  };

  return ASCellNodeBlock;
}

结果:

在此处输入图像描述

于 2016-12-29T15:49:45.190 回答