I’m subclassing UITextField and want to assign to its rightView property a custom button.
I setup the button in setFrame of the subclass.
My textfields had their outlet connections in the ViewController and Class set to my subclass in Identity Inspector in Interface Builder.
The problem is that my custom button is not appearing.
I’ve tried to overcome the problem and made a setupRightView method in my subclass.
Then, when I call setupRightView on the outlet property from the View Controller – voila – everything is working just fine!
I’m fairly new to Objective-C and I suppose I’m making some stupid mistake with the object model.
Why I can’t set correctly rightView property in my subclass?
Did you remember to do this:
self.rightViewMode = UITextFieldViewModeAlways;
That property is set to UITextFieldViewModeNever by default, so you won’t see your button if you don’t include that line.
After Edit: I checked on putting my code in setFrame, and it didn’t work there — not sure why. It worked fine if I put it in awakeFromNib.