tags:

views:

33

answers:

1

I got a little app that has a button whose click is handled via

- (IBAction)click:(id)sender { }

Now, what I want is after click() runs, I want the view to refresh/reload itself, so that viewWillAppear() is re-called automatically. Basically how the view originally appears.

Of course I can call viewWillAppear manually, but was wondering if I can get the framework to do it for me?

A: 

viewWillAppear is where to put code for when your view will appear, so it is more appropriate to put code that will be called repeatedly into another method like -resetView, which can then be called by both viewWillAppear and your click method. You can then call setNeedsDisplay from within resetView.

-(void)resetView
{
    //reset your view components.
    [self.view setNeedsDisplay];
}

-(void)viewWillAppear
{
    [self resetView];
}


- (IBAction)click:(id)sender
{
    [self resetView];
}
Peter DeWeese
I see what you're saying, I guess it doesn't make sense to "get" viewWillAppear to get called while staring at the same view.
Maverick