ios - tableFooterView 属性中的 UIView 不适合 UITabelView 的 ScrollView

标签 ios uitableview

我这样设置 tableView 的 tableFooterView:

UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(10, 10, footerView.bounds.size.width - 20, 44)];
[button setBackgroundImage:[UIImage imageNamed:@"addItemButton.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:button];
self.tableView.tableFooterView = footerView;

但是,当我滚动到 tableview 的最底部时,我的按钮被切断了。

如何确保显示整个按钮?

最佳答案

问题没有说明按钮是否被 scrollview 没有足够向下滚动所切断。但如果是这种情况,您必须更改 UITableViews (UIScrollView) contentsize。

CGSize wholesize =  self.tableView.contentSize;

wholesize.height = self.tableView.contentSize.height + self.tableView.tableFooterView.frame.size.height;

self.tableView.contentSize = wholesize;

希望对您有所帮助。

关于ios - tableFooterView 属性中的 UIView 不适合 UITabelView 的 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12050054/

相关文章:

ios - 警告 : attempt to present

ios - 在 iOS 中预览 Dropbox 文件

ios - UITableViewCell 与 AFNetworking setImageWithURL 太大

ios - 无法将委托(delegate)分配给 UITextField,因为它位于 Tableview 中

ios - Table View 窗外屏幕 iOS objective C

ios - 在代码中设置自动布局约束时的奇怪问题

ios - 屏幕加载时AVPLayer显示黑屏

ios - UICollectionViewCell 中的自动布局不起作用

ios - 在应用程序扩展中检测方向的最佳方法是什么?

ios - 在底部添加单元格并滚动 UITableView