dzenbot / DZNEmptyDataSet

A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display
https://www.cocoacontrols.com/controls/dznemptydataset
MIT License
12.09k stars 1.73k forks source link

DZNEmptyView insert tableview atIndex 0 #352

Open zhangXiaoMing0 opened 7 years ago

zhangXiaoMing0 commented 7 years ago

The previous version addSubview now addSubview ,tableview emptyview insterSubview back forever,So that other views will be displayed on it.How to solve this problem?

    DZNEmptyDataSetView *view = self.emptyDataSetView;
    if (!view.superview) {
        // Send the view to back, in case a header and/or footer is present
        if (([self isKindOfClass:[UITableView class]] || [self isKindOfClass:[UICollectionView class]]) && self.subviews.count > 1) {//                [self insertSubview:view atIndex:];
            [self addSubview:view];
        }
        else {
            [self addSubview:view];
        }
    }

now if (!view.superview) { // Send the view all the way to the back, in case a header and/or footer is present, as well as for sectionHeaders or any other content if (([self isKindOfClass:[UITableView class]] || [self isKindOfClass:[UICollectionView class]]) && self.subviews.count > 1) { [self insertSubview:view atIndex:0]; } else { [self addSubview:view]; } }

JRJian commented 7 years ago

+1