一个UITableView的固定页脚。 总是在页脚位置(Fixed footer of a UI

2019-09-16 15:20发布

我试着去必须在一个UITableView底部固定页脚。 它总是会在底部,不与表格单元格滚动。 它也不能切出来,像盖细胞uitable视图的最后一个单元格这样一个细胞将被隐藏。 我有以下的头文件:

//fooer contains a number_of_total_clicks label, an a proceedtopayment button. 
@interface checkout : UITableViewController

@property (retain, nonatomic) IBOutlet UILabel *number_of_total_clicks;
- (IBAction)proceedtonextview:(id)sender;
@property (retain, nonatomic) IBOutlet UIView *footer; //?
@property (strong, nonatomic) NSMutableDictionary *items_clicked;
@end

and in my .m file

- (void)viewDidLoad
{
    [super viewDidLoad];
    //self.tableView.tableFooterView= footer; ??
    number_of_total_clicks.text=@"0";
}

//void or IBAction?V
- (void)add_item_to_array_of_clicks_which_will_increment_number_of_total_clicks_value:(id)sender{
    number_of_total_clicks.text=[NSString stringWithFormat:@"$%.2f",[sender doubleValue]*5];
    [self.tableView reloadData];
}

会发生什么事是我得到一个页脚基本上是连接表中的最后一个单元格,所以如果表只有3个单元,“页脚”与number_of_total_clicks将作为第四单元连接。 如果有45个细胞,他页脚将是他第46次仅细胞入店一次我滚动一路下跌。 我希望它Ø被固定在底部。 谢谢

Answer 1:

在您的-loadView方法尝试手动创建一个使用您的看法[UIScreen mainScreen]. applicationFrame [UIScreen mainScreen]. applicationFrame作为帧。 请注意,您应该使用UIView ,没有表视图。
此视图将充满整个屏幕(除选项卡和导航栏,使用它们时)。

然后,您可以手动添加UITableView作为VC的tableView ,但不要让它充满整个视图。 在底部留有一定的空间,一样多以适应你的“表尾”,记住设置tableView有一个灵活的宽度,以及灵活的高度。

现在的“表尾”只是将其添加为子视图self.view (不self.tableView ),并将其放置在最底部self.view 。 该视图应具有柔性宽度和柔性顶余量。

我希望这符合您的需求。



文章来源: Fixed footer of a UItableview. always at the footer position