{"id":26621701,"url":"https://github.com/zhitrend/autocelltextview","last_synced_at":"2025-08-01T00:02:38.391Z","repository":{"id":87498782,"uuid":"137294932","full_name":"zhitrend/AutoCellTextView","owner":"zhitrend","description":"UITableview中添加UITextView,不去处理textView文字让tableview高度自动添加","archived":false,"fork":false,"pushed_at":"2018-06-14T02:27:25.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T09:17:40.334Z","etag":null,"topics":[],"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/zhitrend.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":"2018-06-14T02:19:02.000Z","updated_at":"2018-06-15T06:45:15.000Z","dependencies_parsed_at":"2023-12-01T08:30:19.238Z","dependency_job_id":null,"html_url":"https://github.com/zhitrend/AutoCellTextView","commit_stats":null,"previous_names":["zhitrend/autocelltextview"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhitrend/AutoCellTextView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhitrend%2FAutoCellTextView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhitrend%2FAutoCellTextView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhitrend%2FAutoCellTextView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhitrend%2FAutoCellTextView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhitrend","download_url":"https://codeload.github.com/zhitrend/AutoCellTextView/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhitrend%2FAutoCellTextView/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266884588,"owners_count":24000738,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-24T09:17:42.696Z","updated_at":"2025-07-24T18:04:20.036Z","avatar_url":"https://github.com/zhitrend.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AutoCellTextView\n面试题：UITableview中添加UITextView,不去处理textView文字让tableview高度自动添加\n原理：\n1、使用UITableView+FDTemplateLayoutCell和Masonry结合自动布局扩展高度\n2、通过cell中的textView的内容变化代理让tableView重新处理高度\n\n主要代码实现\n```\n// cell中textView内容代理到控制器\n- (void)cellTextViewDidChange:(UITextView *)textView {\n    CGSize maxSize = CGSizeMake(textView.bounds.size.width, CGFLOAT_MAX);\n    CGSize newSize = [textView sizeThatFits:maxSize];\n    CGRect bounds = textView.bounds;\n    bounds.size = newSize;\n    textView.bounds = bounds;\n    [self.tableView beginUpdates];\n    [self.tableView endUpdates];\n}\n```\n\n```\n// tableViewCell高度处理\n-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {\n    AutoTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];\n    CGRect rect = cell.textview.bounds;\n    if (rect.size.height != 0) {\n        return rect.size.height;\n    }\n    return [tableView fd_heightForCellWithIdentifier:identifier cacheByIndexPath:indexPath configuration:^(AutoTableViewCell *cell) {\n        cell.data = @{};\n    }];\n}\n```\n\n\n```\n// FDTemplateLayoutCell和Masonry结合自动布局扩展高度\n   [self.textview mas_remakeConstraints:^(MASConstraintMaker *make) {\n        make.top.equalTo(self.contentView.mas_top);\n        make.left.equalTo(self.contentView.mas_left);\n        make.right.equalTo(self.contentView.mas_right);\n        make.height.lessThanOrEqualTo(@300);\n        make.height.greaterThanOrEqualTo(@150);\n        make.bottom.equalTo(self.contentView.mas_bottom);\n    }];\n```\n\n            \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhitrend%2Fautocelltextview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhitrend%2Fautocelltextview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhitrend%2Fautocelltextview/lists"}