1

在我的应用程序中,我一般不使用 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;
    }

然后将此节点添加为列表的一部分并与列表一起滚动,我需要它作为固定标题。

4

2 回答 2

0

initWithASDisplayNode而不是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];
}
于 2020-05-14T04:22:02.883 回答
-2

(i) 以 A 类为基类。(ii) 将 B 类作为具有 A 类类型的派生类。

现在在 A 类顶部添加一个 uiview。这将被视为导航。(在该视图中执行任何操作)

要使用相同的导航栏:您必须将其他所有类视为具有类 A 的类型。

而已。

于 2017-04-17T08:11:54.760 回答