Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewCell未响应setNeedsLayout_Ios_Objective C_Uitableview_Uiview - Fatal编程技术网

Ios UITableViewCell未响应setNeedsLayout

Ios UITableViewCell未响应setNeedsLayout,ios,objective-c,uitableview,uiview,Ios,Objective C,Uitableview,Uiview,我有一个分组格式的UITableView,其中有几个单元格。单元格中有一个UIView,我正在向其中添加另一个UIView。当我更新第一个UIView的框架时,它不会更改其位置或大小 ui视图如果单元格再次出现屏幕外和屏幕上,则会正确地重新对齐,因此实际的转换正在应用,只是重新渲染没有正确进行 这方面的代码就在myCellForRowatineXpath中: [cell.cellMoney setBackgroundColor:[UIColor clearColor]]; [cell.cell

我有一个分组格式的
UITableView
,其中有几个单元格。单元格中有一个
UIView
,我正在向其中添加另一个
UIView
。当我更新第一个
UIView
的框架时,它不会更改其位置或大小

ui视图
如果单元格再次出现屏幕外和屏幕上,则会正确地重新对齐,因此实际的转换正在应用,只是重新渲染没有正确进行

这方面的代码就在my
CellForRowatineXpath
中:

[cell.cellMoney setBackgroundColor:[UIColor clearColor]];

[cell.cellMoney.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

UIView *sellMoneySubView = [UIMoneyDisplay createViewWithAmount:item.min_sale_unit_price fontSize:17.0];
[cell.cellMoney setFrame:CGRectMake(cell.frame.size.width-sellMoneySubView.frame.size.width-20, 7, sellMoneySubView.frame.size.width, sellMoneySubView.frame.size.height)];

[cell.cellMoney addSubview:sellMoneySubView];

[cell setNeedsLayout];
我添加到第一个
UIView
的子
UIView
被正确添加和渲染,只是第一个的位置变得奇怪

哦,我还在故事板上使用自动布局

另外:我修复了部分问题,但标题仍然有效。我还有一个需要通过网络下载图像的单元格,但该单元格也不响应任何形式的布局调用

我修复了
UIView
位置的问题,方法是删除中间视图并直接添加到单元格的
contentView

[cell setNeedsLayout]
使用
[需要单元格布局]

[cell.cellMoney setBackgroundColor:[UIColor clearColor]];

[cell.cellMoney.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

UIView *sellMoneySubView = [UIMoneyDisplay createViewWithAmount:item.min_sale_unit_price fontSize:17.0];
[cell.cellMoney setFrame:CGRectMake(cell.frame.size.width-sellMoneySubView.frame.size.width-20, 7, sellMoneySubView.frame.size.width, sellMoneySubView.frame.size.height)];

[cell.cellMoney addSubview:sellMoneySubView];

[cell layoutIfNeeded]; //use this
return cell;

这可能会对您有所帮助:)

感谢您对其进行编辑。我完全忘记了将类名放在代码格式中。请阅读以下内容:我试过了,它不起作用<代码>设置需要显示也不起作用。