I am creating a UIView
class . in the implementation there is a function
- (id)initWithFrame:(CGRect)frame
I am adding a button in the class which is used to reload the class.
I would like to call the class initialization function when the button is pressed so that the view is refreshed and it comes back to its intialization state.
Is there a function which can be used to roll back the view to it开发者_开发问答s intialized state?
You should not call -init
methods more then once for the same object.
The solution for your problem however is simple - move all your setting properties code to a separate function, e.g. -setupDefaultProperties
and call it in your initWithFrame method and whenever you want to reset the view to its initial state
精彩评论