I need UITextField
with little customization.
I've created new custom class CustomTextField. In IB I created outlet
for each of my custom UITextField
. I run the code and customization was not working.
To make check I put breakpoint on initialization procedure initWithFrame
in the custom UITextField
. The breakpoint was not hit. I suppose that additional init
must be made in each View Controller, but I am not sure what exactly.
As I created outlet I suppose that init
will be made automatically, but because this is a custom class it must be init
manually with construction like that:
CustomTexTField *textField = [[CustomTextField alloc] initWithFrame:customFrame];
[self.view addSubView:textField];
So do I need additional init
in each View controller and how to do that?
When initializing a view from IB or a storyboard,
initWithCoder
is the initializer used, notinitWithFrame
, and is why the breakpoint is not being hit. Put the customization code in theinitWithCoder
method. E.g.: