2016-12-29 61 views
0

我用facebook's AsyncDisplayKi t運行我的項目,在那裏我找到一個名爲「ASDKgram」的示例項目。它使用節點而不是TableViewCells。默認情況下,'AsTableNodes'又名TableView顯示在屏幕的邊界上。如何在AsyncDisplayKit中爲AsTableNode創建一個框架?

我希望我的tableViewAsTableNodes從uiScreen的每個邊緣顯示10pixels

問題:如何創建具有該特定框架的AsTableNodes?

如果有人已經通過AsyncDisplayKit,請回復並回答。

這裏是鏈接到該項目https://github.com/facebook/AsyncDisplayKit/tree/master/examples/ASDKgram

在此先感謝。

回答

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; 
} 

結果:

enter image description here

+0

讓我檢查上,並會盡快給你 – fAiSaL

+0

我換表collectionnode ......現在它perfeclty – fAiSaL

相關問題