{"id":16753212,"url":"https://github.com/coder-dongjiayi/uiscrollview-tdscrollview","last_synced_at":"2025-07-07T22:11:32.306Z","repository":{"id":98976863,"uuid":"318091407","full_name":"coder-dongjiayi/UIScrollView-TDScrollView","owner":"coder-dongjiayi","description":"集成MJRefresh和UIScrollView+EmptyDataSet 用最少的代码处理刷新和空白页面","archived":false,"fork":false,"pushed_at":"2020-12-21T08:44:18.000Z","size":727,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T18:11:18.716Z","etag":null,"topics":["mjrefresh","uiscrollview-emptydataset","uiscrollview-tdscrollview"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder-dongjiayi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-03T05:58:34.000Z","updated_at":"2021-03-12T09:17:24.000Z","dependencies_parsed_at":"2023-04-05T14:19:24.053Z","dependency_job_id":null,"html_url":"https://github.com/coder-dongjiayi/UIScrollView-TDScrollView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder-dongjiayi%2FUIScrollView-TDScrollView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder-dongjiayi%2FUIScrollView-TDScrollView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder-dongjiayi%2FUIScrollView-TDScrollView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder-dongjiayi%2FUIScrollView-TDScrollView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder-dongjiayi","download_url":"https://codeload.github.com/coder-dongjiayi/UIScrollView-TDScrollView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830614,"owners_count":20354838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mjrefresh","uiscrollview-emptydataset","uiscrollview-tdscrollview"],"created_at":"2024-10-13T02:49:34.602Z","updated_at":"2025-03-16T05:26:21.519Z","avatar_url":"https://github.com/coder-dongjiayi.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 用最简单的方式处理下拉刷新和空白页面处理\n## 依赖\n* MJRefresh\n* DZNEmptyDataSet\n## 为什么会使用UISCrollView-TDScrollView\n* 如果给一个``` scrollview ```添加下拉刷新你可能会这样写\n   ```\n   \n   self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{\n  \n   }];\n\n   self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{\n  \n   }];\n   ```\n\n* 当你需要显示空白页面的时候你也许会这样写\n   ```\n       if(list.count == 0){\n          empty.hidden = false\n       }else{\n         empty.hidden = true\n       }\n   ```\n我认为工程中大量如此的代码，不够美观，不够优雅，所以我觉得应该有更好的实现方式\n  \n## 如何使用\n\n1. 设置``` tableView```或者```collectionView```的delegate\n\n   ```\n   tableView.tdDelegate = self\n   ```\n\n2. 实现``` TDScrollviewDelegate```协议 如果需求只需要下拉刷新那么只需要实现``` tdClientBeginRefresh``` 如果只需要上拉加载更多那么只需要实现```tdClientLoadMoreRefresh ```\n\n   ```swift\n   extension HomeParttimeListView:TDScrollviewDelegate{\n       func tdClientBeginRefresh() {\n         page = 1\n       }\n       func tdClientLoadMoreRefresh() {\n         page = page + 1\n       }\n   }\n   ```\n\n3. 刷新数据(无需关心此时是下拉刷新还是上拉加载更多 请直接调用 td_reload()方法)\n\n   ```swift\n    if page == 1 {\n               dataSource = source\n       }else{\n               dataSource.append(contentsOf: source)\n      }\n   tableView.td_reload(source.count)\n   ```\n\n   \n\n## 解释\n\n1. ``` td_reload```这个方法传入一个count 如果 count=0 那么认为就没有下一页数据了,就会显示没有更多数据\n\n2. 为什么没有使用gitHub上的 [UIScrollView+EmptyDataSet](https://github.com/dzenbot/DZNEmptyDataSet) ？因为这个库有bug，我改了下源码 所以如果你的工程里使用了 ``` DZNEmptyDataSet``` 你可以删除你工程的，使用我这里面的 完全兼容。\n3. 为什么没有制作成pod集成？因为每家公司的下拉刷新显示的空白页面或者默认文案都不一样，你可以把这份代码放到你自己的工程里，根据你公司产品的要求 进行定制。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder-dongjiayi%2Fuiscrollview-tdscrollview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder-dongjiayi%2Fuiscrollview-tdscrollview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder-dongjiayi%2Fuiscrollview-tdscrollview/lists"}