简体   繁体   English

如何在UIView Swift中重新加载特定的子视图?

[英]how to reload particular subview in UIView swift?

In main UIView , I have 3 subviews. 在主UIView ,我有3个子视图。 I want to refresh only one subview. 我只想刷新一个子视图。

My problem, i took array in one subview when i want to remove index of array in subview and refresh it it wont be. 我的问题,当我想在子视图中删除数组的索引并刷新它时,我在一个子视图中使用了数组。

I did try this method. 我确实尝试过这种方法。

  1. - (void)layoutSubviews

  2. - (void)layoutIfNeeded

As well as: 以及:

- (void)setNeedsLayout

You can create a delegate relationship between your UIVIew and UIViewController classes. 您可以在UIVIew和UIViewController类之间创建委托关系。 Then add the proper code inside delegate methods to reload the UIVIew. 然后在委托方法中添加适当的代码以重新加载UIVIew。

Otherwise you can call setNeedsDisplay on your view thereby you're forcing it to redraw. 否则,您可以在视图上调用setNeedsDisplay ,从而迫使其重新绘制。 That is not the correct way of doing this. 这不是正确的方法。

Totorial to make Delegates 委托人指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM