gpt4 book ai didi

ios - UIButton 低于 UITableView 但高于 TabBar

转载 作者:行者123 更新时间:2023-11-29 10:53:03 28 4
gpt4 key购买 nike

如何在 UITableView 下方但在 TabBar 上方放置一个按钮,以便 UIButton 保持静止(不随 tableview 滚动)?

这是一张我想要帮凶的照片:http://i.imgur.com/dY4CsDC.png

最佳答案

简单!

在您使用 tableview 的 UIViewController 类中,您只需添加到与 subview 相同的 ViewControllers View 按钮并重新定位它们,以便它们每个都有自己的空间。

所以..

_tableView = [[UITableView alloc] init];

[_tableView setDataSource:self];

[_tableView setDelegate:self];

[_tableView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];

// Use 64 to allow for the naviation bar on top and 160 to allow for tabbar and button
[_tableView setFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-160)];

[[self view] addSubview:_tableView];



_aButtonUnderTableView = [UIButton new];

[_aButtonUnderTableView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];

// use 50 for the height
[_aButtonUnderTableView setFrame:CGRectMake(0, self.view.frame.size.height-100, self.view.frame.size.width, 50)];

[_aButtonUnderTableView setTitle:@"Custom Button Title" forState:UIControlStateNormal];

[_aButtonUnderTableView setBackgroundColor:[UIColor redColor]];

[_aButtonUnderTableView addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];

[[self view] addSubview:_aButtonUnderTableView];

现在 - tableview 应该有所有可用空间,但从底部留下 100 像素的偏移量。并且它会自动调整大小,在双状态栏的情况下在底部留下 100 像素。

并且按钮将保留在底部(即使在双状态栏的情况下)- 始终具有可见的 100 像素高度。

关于ios - UIButton 低于 UITableView 但高于 TabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19623707/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com