大佬教程收集整理的这篇文章主要介绍了ios – 更新单元子视图的约束,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
CustomeCell.m
-(void)layoutSubviews { [super layoutSubviews]; _con_view_width.constant = _lbl_property.frame.size.width; if(!_btn_imageCount.isHidden) _con_view_width.constant = _lbl_property.frame.size.width + _btn_imageCount.frame.size.width; NSLog(@"%@",NSStringFromCGRect(_view_lbl_btn.framE)); [_view_lbl_btn updateConsTraintsIfNeeded]; NSLog(@"%@",NSStringFromCGRect(_view_lbl_btn.framE)); }
问题
只有在滚动时重新加载行时,约束才起作用
-(void)layoutSubviews { [super layoutSubviews]; _con_view_width.constant = _lbl_property.frame.size.width; if(!_btn_imageCount.isHidden) _con_view_width.constant = _lbl_property.frame.size.width + _btn_imageCount.frame.size.width; NSLog(@"%@",NSStringFromCGRect(_view_lbl_btn.framE)); [_view_lbl_btn layoutIfNeeded]; NSLog(@"%@",NSStringFromCGRect(_view_lbl_btn.framE)); }
编辑:如果您在自定义单元格类中执行此操作,则需要在索引路径的行中为单元格@L_874_6@一行.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; //[cell layoutIfNeeded]; [cell layoutSubviews]; return cell; }
以上是大佬教程为你收集整理的ios – 更新单元子视图的约束全部内容,希望文章能够帮你解决ios – 更新单元子视图的约束所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。