Search code examples
iphoneuiviewreloadsubview

Reload all subViews of current ViewController


I have a situation where i have to reload all subViews of my current view....I am adding all objects(like buttons, images ...etc) from interface builder.....

And i want to reset these subviews when user click on a button...

i tried [self.view setNeedsDisplay]; but it doesn't works.

Is there any simple way to do this...

Any suggestion?


Solution

  • Reloading them sounds like the wrong thing to do. You can easily reset them to their default state programmatically by setting the various properties to your defaults. Once you do that I would probably just create the whole view and subviews programmatically without using IB. I do everything programmatically now and find it easier to maintain my code.

    You could come up with a NIB based solution by putting all affected subviews within a parent UIView and load just that parent view from a NIB and then replace the parent UIView only but I don't recommend it. You need to able to set subview properties programmatically in viewDidLoad anyway in case the view controller needs to unload/reload the view based on memory warnings.