How to reload my UIViewController when clicking some buttons?

I am developing an application for the iPhone, I have a class UIViewControllerwhere there are some flow animations, and by design I have 5 buttons on top of my view. Each button has a method IBActionwhen I click. I need to display a different set of flow around with different data, and the coverage counter also changes from the action of 1 button to another. My problem is how can I refresh my page (reload) when I click these buttons, since I know that explicit calling viewDidLoadis a very bad idea, so how can I do this? Any help is appreciated in advance, thanks.

+5
source share
6 answers

The easiest way to get a view for re-drawing is to call [UIView setNeedsDisplay] or using [UIView setNeedsDisplayInRect]. This method tells him to re-draw himself, and he examines it. However, you do not always have to call it. There are other methods that may cause you to view lists. For example, if you add or remove a view to the view hierarchy using [UIView addSubview:] or [UIView removeFromSuperview].

drawInRect: view (, ). , , , .

. , " ".

http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

+6

?, , , , :

setNeedsDisplay();

, , , .

+3

, viewDidLoad, , . , , . , setNeedsDisplay . , .

+1

"UIViewController", :

[self viewDidLoad];

: UIViewController ?

+1
To Refresh your UIViewController, When Clicking the button >>

Add the below code into your UIButton method,

-(IBAction)button:(id)sender{
    [self viewDidLoad];
    [self viewWillAppear:YES];
}

Now Build and Run Your Code. 
0

Use the viewWillAppear () function. This function is called every time the view is called.

-7
source

All Articles