0

I have a tableView ("tableView") with a UIScrollView (when the user scrolls the tableView changing its position), I want that when the user "over-scrolls" the tableView up, there will be a white UIView ("whiteViewUnderAroundersTableView") that goes from the bottom of the tableView, an example of the scroll: scroll example

My code:

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

The error in the log:

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...
Yhper
  • 183
  • 2
  • 14

3 Answers3

0

The tableView is a sub-class of UIScrollView, so it is not necessary to add a tableView as a child view of UIScrollView. When you set the delegate of a tableView, the delegate is for UITableViewDelegate, and it is also for UIScrollViewDelegate.

Moreover, you can add a custom view as a tableFooterView property of tableView. The tableFooterView will put on the bottom of tableView.

AechoLiu
  • 17,522
  • 9
  • 100
  • 118
0

If I understand what you're saying correctly, in general you should not embed a tableView in a scrollView to accomplish this goal. When you do this, iOS has no way to tell if a swipe up/down was intended for the tableview or the scrollview since they are both scrollable!

Per: How to use UITableView inside UIScrollView and receive a cell click?

tableFooterView is a much better option:

tableView.tableFooterView = UIView( ... )
Community
  • 1
  • 1
Jake Spracher
  • 805
  • 7
  • 10
0

Simply call this 2 delegate methods

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

return 60;

}

- (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;

}

Jamil
  • 2,977
  • 1
  • 13
  • 23