我使用facebook's AsyncDisplayKit来运行我的项目,在那里我找到了一个名为"ASDKgram“的示例项目。它使用节点而不是TableViewCells。默认情况下,'AsTableNodes‘又名TableView将显示在屏幕的边界上。
我希望将我的tableView或AsTableNodes从uiScreen的每个边缘显示为10pixels。
问题:如何使用特定的框架创建AsTableNodes?
如果有人已经通过了AsyncDisplayKit,请回答。
下面是指向该项目https://github.com/facebook/AsyncDisplayKit/tree/master/examples/ASDKgram的链接
提前谢谢。
发布于 2016-12-29 15:49:45
使用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;
}结果:

https://stackoverflow.com/questions/41374233
复制相似问题