【问题标题】:Fixed footer of a UItableview. always at the footer position修复了 UItableview 的页脚。总是在页脚位置
【发布时间】:2012-04-18 18:43:57
【问题描述】:

我试图将页脚固定在 uitableview 的底部。它总是在底部,不能用表格单元格滚动。它也不能剪掉,像覆盖可用视图的最后一个单元格这样的单元格,所以一个单元格将被隐藏。我有以下头文件:

//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 的“页脚”将作为第 4 个单元格附加。如果有 45 个单元格,则页脚将是第 46 个单元格,只有在我一直向下滚动时才能访问。我想把它固定在底部。谢谢

【问题讨论】:

    标签: iphone uitableview css-position table-footer


    【解决方案1】:

    在您的-loadView 方法中,尝试使用[UIScreen mainScreen]. applicationFrame 作为框架手动创建您的视图。请注意,您应该使用UIView,而不是表格视图。
    此视图将填满整个屏幕(使用时,标签和导航栏除外)。

    然后您可以手动添加一个UITableView 作为 VC 的tableView,但不要让它填满整个视图。在底部留出一些空间,以适应您的“表格页脚”。记住将tableView 设置为具有灵活的宽度和灵活的高度。

    现在对于“表格页脚”,只需将其作为子视图添加到self.view(不是self.tableView)并将其放在self.view 的最底部。这个视图应该有一个灵活的宽度和一个灵活的上边距。

    我希望这符合您的需求。

    【讨论】:

    • 抱歉,您能详细说明一下吗?我无法以编程方式进行操作。如何将它放在 self.view 的最底部?
    猜你喜欢
    • 1970-01-01
    • 2021-06-08
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 2016-06-26
    • 1970-01-01
    • 2012-06-01
    相关资源
    最近更新 更多