AlexanderN
AlexanderN

Reputation: 2670

UIButton as subview to UITextfield

I have a subview: UITextfield that is being repositioned when an orientation change occurs. I would like ti add a UIButton to this subview so that the button will reposition with the UITextField.

This is easy to do, but for the button to work I need to set the UITextField to be userInteractionEnabled. The problem is that I need it not to be userInteractionEnabled.

Anyone know of a good solution for this?

Upvotes: 1

Views: 607

Answers (1)

HackyStack
HackyStack

Reputation: 5157

The best solution is to create a UIView (a container view) then add the textfield and button to that view. Then add this container view to your main view and reposition the container view as necessary. Then the textfield and button will follow...

Upvotes: 3

Related Questions