A tableview which scrollview and the tableview can scroll to right
self.tableView = [[UITableView alloc]init];
self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
self.tableView.backgroundColor = [UIColor whiteColor];
[self.tableView setAllowsSelection:NO];
//build the scrollabe view
self.scrollView = [[UIScrollView alloc] init];
self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
// add subview tree
[self.scrollView addSubview:self.tableView];
[self.view addSubview:self.scrollView];
//build footer view
self.footerView = [[DetailsTableVTViewFooterView alloc] init];
self.footerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.footerView];
[self.footerView.saveButton addTarget:self action:@selector(saveLocalChanges) forControlEvents:UIControlEventTouchUpInside];
// Using Masonry for autolayout
[self.footerView makeConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(@footerHeight);
make.width.equalTo(frame.size.width);
make.right.equalTo(self.view.right);
}];
self.scrollView.backgroundColor = [UIColor redColor];
[self.scrollView makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view.right);
make.left.equalTo(self.view.left);
make.top.equalTo(self.view.top);
make.bottom.equalTo(self.footerView.top);
}];
[self.tableView makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(tableViewWidth);
make.bottom.equalTo(self.footerView.top);
make.left.equalTo(self.scrollView.left);
make.right.equalTo(self.scrollView.right);
make.top.equalTo(self.scrollView.top);
}];