I have a UITextField that I would like to make "taller" than one line of long text. In the Interface Builder for this object, I can increase the width of the text field, but the not the height, as the latter is grayed-out and fixed at the value "31".
Can one increase the height of a text field, and if so, how?
Have you checked to see if UITextFields have an initWithFrame method? I'm away from my iMac, otherwise I'd check for you. What you're wanting to do may not be possible using interface builder.
Also, instead of using a UITextField, you could use a UITextView and put a picture of a box with rounded edged behind it. UITextViews work the same way as UITextFields, only they're more easily adjusted to fit larger areas.
I have a UITextField that I would like to make "taller" than one line of long text. In the Interface Builder for this object, I can increase the width of the text field, but the not the height, as the latter is grayed-out and fixed at the value "31".
I ran into this myself. It looks like the height of the rounded-style text field is locked in Interface Builder. My solution was to use another of the UITextField styles in my XIB and then call textField.borderStyle = UITextBorderStyleRoundedRect in my viewDidLoad method.
Of course, 'textField' should be the name of the UITextField IBOutlet.
I don't quite follow how you increased the height of the textField using a border style. Can you please elaborate?
In IB, it appears that text fields with the rounded border style are the only ones that cannot be resized. When I changed switched the another of the border styles in my XIB file, the height field in the Size tab was enabled. At that point, I was able to set the height to what I desired.
Then, in my view controller implementation, I switched my text field to the desired border style.
So to get the size you want in IB, you toggle away from rounded rectangle, resize the textField per your need, then reset the border style somewhere in your code before the view is rendered?
Nicely done :-) But that you had to resort to this at all is a little strange. C
So to get the size you want in IB, you toggle away from rounded rectangle, resize the textField per your need, then reset the border style somewhere in your code before the view is rendered?
Nicely done :-) But that you had to resort to this at all is a little strange. C
I'm not on my mac atm, but I vaguely remember using myTextField.LineNumbers or similar property to set lines in code. What I found nice was that if I set it to some large number, say 100, but there is only 2 lines it will not take space for 100 lines but 2 lines only..
Has anybody found the solution to this, actually i wanted to make a screen similar to the iPhone SMS screen, where the user can enter the message (the textfield expands as a message is entered)
I did exactly as mentioned and it works fine. But when I type in the textfield the text doesnot flow in to the next line but it goes on in the same line.