Ios 在TableView的底部添加UIView

Ios 在TableView的底部添加UIView,ios,objective-c,iphone,uiview,uiscrollview,Ios,Objective C,Iphone,Uiview,Uiscrollview,我有一个带有UIScrollView的tableView(“tableView”)(当用户滚动tableView改变其位置时),我希望当用户向上“滚动”tableView时,会有一个白色的UIView(“WhiteViewUnderAroUnderstandbleView”),从tableView的底部开始,滚动的一个示例: 我的代码: //Creating "whiteViewFrame", a frame for "whiteViewUnderTableView"(a white view

我有一个带有UIScrollView的tableView(“tableView”)(当用户滚动tableView改变其位置时),我希望当用户向上“滚动”tableView时,会有一个白色的UIView(“WhiteViewUnderAroUnderstandbleView”),从tableView的底部开始,滚动的一个示例:

我的代码:

//Creating "whiteViewFrame", a frame for "whiteViewUnderTableView"(a white view in the scrollView that goes behind the "tableView" and shows a white view when Over-Scrolling up) with the Y position of the end of the "tableView"
CGRect whiteViewFrame=CGRectMake(self.whiteViewUnderTableView.frame.origin.x, CGRectGetMaxY(self.tableView.frame), self.whiteViewUnderTableView.frame.size.width, self.whiteViewUnderTableView.frame.size.height);

//Changing "whiteViewUnderTableView"'s frame to "whiteViewFrame"
self.whiteViewUnderTableView.frame=whiteViewFrame;

//Changing "whiteViewUnderAroundersTableViewTopConstraint" (Y coordinate constraint of "whiteViewUnderAroundersTableView")'s constant to "AroundersTableView"'s Y coordinate
self.whiteViewUnderAroundersTableViewTopConstraint.constant=self.whiteViewUnderAroundersTableView.frame.origin.y;
日志中的错误:

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. 
Try this: 
    (1) look at each constraint and try to figure out which you don't expect; 
    (2) find the code that added the unwanted constraint or constraints and fix it...

tableView
UIScrollView
的一个子类,因此无需添加
tableView
作为
UIScrollView
的子视图。设置
表视图的
委托
时,
委托
用于
UITableViewDelegate
,也用于
UIScrollViewDelegate


此外,还可以将自定义视图添加为tableView的
tableFooterView
属性。
tableFooterView
将放在
tableView

的底部。如果我理解正确,一般来说,您不应该在滚动视图中嵌入tableView来实现此目标。当您这样做时,iOS无法判断向上/向下滑动是针对tableview还是scrollview,因为它们都是可滚动的

Per:

tableFooterView是一个更好的选项:

tableView.tableFooterView = UIView( ... )

只需调用这两个委托方法

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

return 60;
}


}

为什么不使用上一个视图创建自定义单元格并在最后显示?您没有在日志中发布整个错误!!!甚至比自定义单元格更好的是,有一个
tableFooterView
属性应该适合您。或表的最后一部分的页脚视图。其中,r u添加代码/
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
CGRect frame = tableView.frame;
frame.size.height = 60;

UIView *footerView = [[UIView alloc]initWithFrame:frame];
footerView.backgroundColor = [UIColor brownColor];

return footerView;