Logan Shire
Logan Shire

Reputation: 5103

How to refresh UIViewController programmatically?

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?

Upvotes: 2

Views: 31712

Answers (4)

Darius Miliauskas
Darius Miliauskas

Reputation: 3504

If your point is to refresh "UIViewController", then:

[self viewDidLoad];

Upvotes: -1

TrevorL
TrevorL

Reputation: 495

Once you have a handle on your view:

UIView *v = ...;
[v removeFromSuperview];

You could also call the setNeedsDisplay method on your scroll view after calling removeFromSuperview.

Upvotes: 0

liv a
liv a

Reputation: 3340

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

Upvotes: 2

leafduo
leafduo

Reputation: 144

You can either let view controller observe your models or update your views manually.

I'm not very clear about your question, what is still remaining on your view?

For automatically update views when model changes, I suggest ReactiveCocoa.

Upvotes: 0

Related Questions