美文网首页
MJRefresh无数据时让mj_footer显示在页面底部

MJRefresh无数据时让mj_footer显示在页面底部

作者: 姬歌 | 来源:发表于2018-08-21 17:14 被阅读1451次

    图中展示的视图为noDataView,添加方法是

    tableView.addSubView(noDataView)
    

    效果如下:


    wrong.png

    很明显这个效果太弱鸡,让人无法接受!mj_footer出现在了noDataView的上方!
    现在,让我们做一些改进,不要直接在tableView上添加这个noDataView,而是把它当做一个section header来处理。

    extension DCHistoryProjectViewController: UITableViewDataSource, UITableViewDelegate {
         //...
        func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
            if completedProjectArray.count == 0 {
                return noDataView.jk_h  //view的高度
            }
            return 0
        }
        
        func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
            if completedProjectArray.count == 0 {
                return noDataView
            }
            return nil
        }
    }
    

    现在,我们可以得到我们想要的效果了:


    right.png

    MJRefresh gitHub链接

    相关文章

      网友评论

          本文标题:MJRefresh无数据时让mj_footer显示在页面底部

          本文链接:https://www.haomeiwen.com/subject/eppjiftx.html