How to refresh UIViewController programmatically?

advertisements

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. in your viewcontroller
  2. directly in the view

you need to call the function 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];

hope this helps