作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我通常不使用 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;
}
然后这个节点被添加为列表的一部分并与列表一起滚动,我需要它作为固定标题。
最佳答案
init用ASDisplayNode
而不是ASTableNode
,然后在VC的节点上添加表节点,例如:
@interface OCTextureTableController : ASViewController<ASDisplayNode *>
@property (nonatomic, strong) ASTableNode *tableNode;
- (instancetype)init
{
self = [super initWithNode:[ASDisplayNode new]];
if (self) {
self.tableNode = [[ASTableNode alloc] init];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableNode.backgroundColor = [UIColor yellowColor];
self.tableNode.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT-NAVIGATION_BAR_HEIGHT);
[self.node addSubnode:self.tableNode];
}
关于ios - 如何在没有 NavigationController 的情况下使用 ASTableNode 在 ASViewController 上添加像 Navigationbar 这样的 headerView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43447554/
在我的应用程序中,我通常不使用 NavigationController。在 UITableView 中我会这样做,会添加 [Self.view addSubview: self.myCustomHe
我是一名优秀的程序员,十分优秀!