[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$fbv7by7lONgs8zzJWCyJmcKH9yEsX5BASB3fOutoMsE4":3},{"code":4,"message":5,"data":6},200,"成功",{"id":7,"createdAt":8,"title":9,"content":10,"summary":11,"image":12,"uid":13,"user":14,"categoryId":21,"category":22,"subCategoryId":24,"subCategory":25,"comments":27,"status":17,"reason":28,"notice":28,"visitCount":29,"commentCount":30,"keywords":31},39,"2024-01-30T04:54:08.277Z","xib中tableviewcell rowheight的高度自适应","\n\n用xib实现高度自适应所应该具有的条件：\n1. 每一个cell中，内容文字显示有多有少，使得每一个cell的高度不能完全一致；\n2. 自定义的cell的xib中，控件的布局从左到右，从上到下进行布局；\n3. xib中最靠近cell Content的控件，要设置相对于content的bottom约束。\n4. 内容文字控件UILabel的xib需要设置lineNumber = 0; 并且Preferred width 要勾选Explicit。\n![xib截图](https://image.xinwei.ltd/11706590380707.png)\n\n5. 需要在对应的控制器中，设置\n```\nUITableView，\n        self.tableView.rowHeight =  UITableViewAutomaticDimension;\n     self.tableView.estimatedRowHeight = 365;\n```\n6. 需要在对应控制器，设置一个cell的实例demoHeightCell的全局cell类实例, \n\n// demo height cell\n    CYCourseDetailTableViewCell *demoHeightCell;\n然后通过nib的loadNib方式实例化\n```\ndemoHeightCell = [[[NSBundle mainBundle] loadNibNamed:@\"CYCourseDetailTableViewCell\" owner:nil options:nil] firstObject];\n```\n然后如下：\n```\n- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{\n    [demoHeightCell  valueWithModel:courseArr[indexPath.row]];\n    CGSize demoSize = [demoHeightCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];\n    return demoSize.height;\n}\n```\n返回计算后的高度，即为理想宽度。\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","在iOS中，如何使用xib来让tableviewCell的row height高度自适应","https://image.xinwei.ltd/11706590380707.png",499668042977349,{"phone":15,"userId":13,"nickName":16,"vipType":17,"avatar":18,"sign":19,"createdAt":20},"13121171998","全栈老韩",1,"https://image.xinwei.ltd/images/IMG_5430.JPG","全栈工程师，擅长iOS App开发、前端（vue、react、nuxt、小程序&Taro）开发、Flutter、React Native、后端（midwayjs、golang、express、koa）开发、docker容器、seo优化等。","2024-01-01T16:14:30.305Z",2,{"id":21,"name":23},"IT技术",3,{"id":24,"name":26,"parentId":21},"iOS",[],"",46,0,"ios xib,ios tableview,xib tableview"]