固定的UItableview页脚。始终位于页脚位置 [英] Fixed footer of a UItableview. always at the footer position

查看:112
本文介绍了固定的UItableview页脚。始终位于页脚位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在uitableview的底部固定页脚。它将始终位于底部,不可与表格单元一起滚动。它还无法剪切,像这样的单元格覆盖了可使用视图的最后一个单元格,因此将隐藏一个单元格。我有以下头文件:

  // fooer包含一个number_of_total_clicks标签和一个procetopayment按钮。 
@interface checkout:UITableViewController

@property(保留,非原子)IBOutlet UILabel * number_of_total_clicks;
-(IBAction)proceedtonextview:(id)sender;
@property(保留,非原子)IBOutlet UIView *页脚; //?
@property(strong,nonatomic)NSMutableDictionary * items_clicked;
@end

和我的.m文件

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

// void或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,[发送方doubleValue] * 5];
[self.tableView reloadData];
}

发生了什么事,我得到了页脚,它基本上附着在的最后一个单元格上表格,因此,如果表格只有3个单元格,则第4个单元格将附加具有number_of_total_clicks的页脚。如果有45个单元格,那么当我一直向下滚动时,页脚将只能是第46个单元格。我希望将其固定在底部。谢谢

解决方案

在您的 -loadView 方法中,尝试使用创建手动视图 [UIScreen mainScreen]。 applicationFrame 作为框架。请注意,您应该使用 UIView 而不是表格视图。

此视图将填满整个屏幕(使用选项卡和导航栏时除外) )。



然后您可以手动添加 UITableView 作为VC的 tableView ,但不要使其填满整个视图。在底部保留一些空间,以适合您的表尾。请记住,将 tableView 设置为具有灵活的宽度和灵活的高度。 / p>

现在将表脚添加为 self.view 的子视图(不是 self.tableView )并将其放在 self.view 的最底部。该视图应该具有灵活的宽度和灵活的顶部边距。



我希望这可以满足您的需求。


Im trying to have a footer Fixed at the bottom of a uitableview. it will always be at the bottom, not scrollable with the table cells. It also cant cut out and cells like cover the last cell of a uitable view so one cell will be hidden. I have the following header file:

//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];
}

What happens is I get a footer the is basically attached to the last cell of the table so if the table has only 3 cells, the "footer" with the number_of_total_clicks will be attached as a 4th cell. if there are 45 cells, he footer will be he 46th cell only accesible once I scroll all the way down. I want it o be fixed a the bottom. Thanks

解决方案

In your -loadView method try manually creating your view using [UIScreen mainScreen]. applicationFrame as the frame. Note that you should use a UIView, not a table view.
This view will fill the whole screen (except for tab and navbars, when using them).

You can then manually add a UITableView as the VC's tableView, but don't make it fill the whole view. Leave some space at the bottom, just as much to fit your 'table footer' in. Remember to set the tableView to have a flexible width as well as a flexible height.

Now for the 'table footer' just add it as a subview to self.view (not self.tableView) and place it at the very bottom of self.view. This view should have a flexible width and a flexible top margin.

I hope this fits your needs.

这篇关于固定的UItableview页脚。始终位于页脚位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆