在我的应用程序中,我一般不使用 NavigationController。在 UITableView 我会这样做,会添加
[Self.view addSubview: self.myCustomHeaderView];
但我正在使用 ASTableNode。如果我做某事,这里有类似的东西:
- (instancetype)init {
_tableNode = [[ASTableNode alloc] init];
self = [super initWithNode:_tableNode];
if (self) {
_tableNode.dataSource = self;
_tableNode.delegate = self;
self.navigationItem = //navigationItem implement
UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
navbar.backgroundColor = [UIColor redColor];
navbar.items = @[self.navigationItem];
ASDisplayNode *navBarNode = [[ASDisplayNode alloc] initWithViewBlock:^UIView * _Nonnull {
return navbar;
}];
[self.node addSubnode:navBarNode];
}
return self;
}
然后将此节点添加为列表的一部分并与列表一起滚动,我需要它作为固定标题。