如何以编程方式刷新UIViewController? [英] How to refresh UIViewController programmatically?

查看:86
本文介绍了如何以编程方式刷新UIViewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ViewController,用户在其中从UIScrollView中选择一张卡片(自定义UIButton)。我截获了触摸事件选择卡并识别它,然后将其从数据源中删除,但它仍然存在于UISubView中。我怎么摆脱它?刷新视图应该会从视图中删除它。我该怎么办?

I have a ViewController in which the user selects a card (a custom UIButton) out of a UIScrollView. I have intercepted the touch event selecting the card and identified it, and then removed it from the data source, but it still exists in the UISubView. How do I get rid of it? Refreshing the view should show it removed from the view. How do I do that?

推荐答案

你可以在两个地方之一做到:

you can do it in one of two places:


  1. 在你的viewcontroller中

  2. 直接在视图中

你需要调用函数setNeedsDisplay

you need to call the function setNeedsDisplay


  1. 如果你从viewController然后执行 [yourViewOutletVariable / viewParameter setNeedsDisplay];

  2. 如果你在视图中编写它然后 [self setNeedsDisplay];

  1. if you do it from the viewController then [yourViewOutletVariable/viewParameter setNeedsDisplay];
  2. if you write it in the view itself then [self setNeedsDisplay];

希望这会有所帮助

这篇关于如何以编程方式刷新UIViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆