下面是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor blueColor];
UITableView *myTableview = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
myTableview.dataSource = self;
myTableview.delegate = self;
myTableview.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:myTableview];
NSLayoutConstraint* widthConstraint = [NSLayoutConstraint constraintWithItem:myTableview attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0];
NSLayoutConstraint* heightConstraint = [NSLayoutConstraint constraintWithItem:myTableview attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.0];
NSLayoutConstraint* topConstraint = [NSLayoutConstraint constraintWithItem:myTableview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
NSLayoutConstraint* leftConstraint = [NSLayoutConstraint constraintWithItem:myTableview attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
[self.view addConstraints:@[widthConstraint,heightConstraint,topConstraint,leftConstraint]];
UIView* footerView = [[UIView alloc] init];
footerView.backgroundColor = [UIColor greenColor];
[myTableview setTableFooterView:footerView];
footerView.frame = CGRectMake(0,0, 320, 60);
}
]