DZNEmptyDataSet customViewForEmptyDataSet方法注意点

DZNEmptyDataSet是使用Autolayout布局,并且自定义View需要设置高度约束来撑起显示内容,所以这里设置frame是没有用的,正确的姿势是:

- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView {
    UIView *view = [UIView new];
    [view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[view(100)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]];
    view.backgroundColor = [UIColor redColor];
    return view;
}

你可能感兴趣的:(DZNEmptyDataSet customViewForEmptyDataSet方法注意点)