Tassos Voulgaris
Tassos Voulgaris

Reputation: 888

Why I cant programmatically change the width of UITextField?

I am trying to programmatically change the width of a UITextField using the following code:

myText.frame = CGRectMake(myText.frame.origin.x, myText.frame.origin.y, 280 ,myText.frame.size.height);

The code above is executed on a "touch up inside" button action.

myText has its border style property set to UITextBorderStyleNone

Any ideas are welcome!

Upvotes: 0

Views: 1283

Answers (2)

Mick MacCallum
Mick MacCallum

Reputation: 130193

My first thought is that either you never linked the IBAction to the UIButton, or there is no IBOutlet pointing to the UITextField.

You can verify that the IBAction is getting called on button press simply by adding an NSLog statement to it, or you can check that both are linked from the "Connections Inspector" in Interface Builder.

Side note Since your text field is set to have no border, it is possible that you just can't tell it is growing. To verify, I would trying setting the text field's background color to something obvious.

Upvotes: 0

Agent Chocks.
Agent Chocks.

Reputation: 1312

if you are trying to set frame programmatically just disable the autolayout for your .xib

Upvotes: 1

Related Questions