gpt4 book ai didi

ios - viewForFooterInSection 未显示在屏幕底部

转载 作者:行者123 更新时间:2023-11-28 21:08:29 24 4
gpt4 key购买 nike

viewForFooterInSection 未显示在屏幕底部 (uitableview)。这里我使用的是 UItableview。 image

注意:在下面的屏幕变化中,屏幕底部又添加了一个页脚。(白色 View )。Redcolorview:页脚(来自下面的代码)蓝色:表格背景色白底:

我使用以下代码以编程方式添加的红色 View :

- (CGFloat)tableView:(UITableView *)tableView 
estimatedHeightForFooterInSection:(NSInteger)section
{
return 44;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
NSLog(@"%f",tableView.frame.size.width);

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 44)];
view.backgroundColor = [UIColor redColor];
UIButton *cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(30, 7, tableView.frame.size.width/2 - 60, 30)];
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cancelButton setBackgroundColor:[ValidationsClass colorWithHexString:NSLocalizedStringFromTableInBundle(@"pothysapp_label_text_backgroundcolor",@"ApplicationSettings",[NSBundle mainBundle], nil)]];
[cancelButton addTarget:self
action:@selector(cancelDetails:)
forControlEvents:UIControlEventTouchUpInside];
cancelButton.titleLabel.font = [UIFont fontWithName:@"Roboto-Bold" size:15];
cancelButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[view addSubview:cancelButton];

UIButton *saveButton = [[UIButton alloc]initWithFrame:CGRectMake(tableView.frame.size.width/2 + 30, 7, tableView.frame.size.width/2 - 60, 30)];
[saveButton setTitle:@"Save" forState:UIControlStateNormal];
[saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[saveButton setBackgroundColor:[ValidationsClass colorWithHexString:NSLocalizedStringFromTableInBundle(@"pothysapp_label_text_backgroundcolor",@"ApplicationSettings",[NSBundle mainBundle], nil)]];
[saveButton addTarget:self
action:@selector(saveDetails:)
forControlEvents:UIControlEventTouchUpInside];
saveButton.titleLabel.font = [UIFont fontWithName:@"Roboto-Bold" size:15];
saveButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[view addSubview:saveButton];

return view;
}

最佳答案

试试这个,而不是在 viewForFooterInSection 中返回您的自定义 View 。

ViewdidLoad() 中将您的自定义 View 添加到表页脚

self.tableview.tableFooterView =//Your CustomView;

关于ios - viewForFooterInSection 未显示在屏幕底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44565750/

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