How to refresh UIViewController programmatically?

后端 未结 4 1588
暗喜
暗喜 2021-01-14 20:08

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,

相关标签:
4条回答
  • 2021-01-14 20:12

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

    [self viewDidLoad];
    
    0 讨论(0)
  • 2021-01-14 20:24

    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.

    0 讨论(0)
  • 2021-01-14 20:32

    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

    0 讨论(0)
  • 2021-01-14 20:38

    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.

    0 讨论(0)
提交回复
热议问题