Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-04-2008, 09:23 AM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 28
ae6rt is on a distinguished road
Default Increasing the height of a UITextField

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?

Thanks.
ae6rt is offline   Reply With Quote
Old 09-04-2008, 10:49 AM   #2 (permalink)
Tutorial Author
 
Join Date: May 2008
Posts: 315
myersn024 is an unknown quantity at this point
Default

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.
myersn024 is offline   Reply With Quote
Old 09-10-2008, 01:57 AM   #3 (permalink)
New Member
 
Join Date: May 2008
Posts: 30
jablair is an unknown quantity at this point
Default

Quote:
Originally Posted by ae6rt View Post
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.
jablair is offline   Reply With Quote
Old 09-10-2008, 07:30 AM   #4 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 28
ae6rt is on a distinguished road
Default

Thanks.

I don't quite follow how you increased the height of the textField using a border style. Can you please elaborate?
ae6rt is offline   Reply With Quote
Old 09-10-2008, 02:03 PM   #5 (permalink)
New Member
 
Join Date: May 2008
Posts: 30
jablair is an unknown quantity at this point
Default

Quote:
Originally Posted by ae6rt View Post
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.
jablair is offline   Reply With Quote
Old 09-10-2008, 02:10 PM   #6 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 28
ae6rt is on a distinguished road
Default

I see.

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
ae6rt is offline   Reply With Quote
Old 09-10-2008, 06:18 PM   #7 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 16
ej2007 is on a distinguished road
Default

Quote:
Originally Posted by ae6rt View Post
I see.

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..
ej2007 is offline   Reply With Quote
Old 10-26-2008, 12:15 PM   #8 (permalink)
ash
Ashar
 
Join Date: Aug 2008
Posts: 54
ash is on a distinguished road
Default

Hi Guys

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)

Any help would be appreciated.

--
Thanks
ash is offline   Reply With Quote
Old 01-13-2009, 12:52 AM   #9 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 5
ramyag is on a distinguished road
Default

Hello All,


Even I am suppose to implement a text input view similar to the one in sms application in iPhone.
Any pointers on this is greatly appreciated.

Thanks in Advance
ramyag is offline   Reply With Quote
Old 01-08-2010, 07:32 PM   #10 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 7
aerialcombat is on a distinguished road
Default I've found the answer I think

You can draw the height of the UITextField programmatically like this.

Code:
UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake(20, 80, 280, 120)];
Then be sure to set the border style of the textfield.

Code:
[field setBorderStyle:UITextBorderStyleRoundedRect];
aerialcombat is offline   Reply With Quote
Old 05-20-2010, 08:19 AM   #11 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
guest is on a distinguished road
Default multi line textfield

Hi,

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.

How do i do a text wrap??

Regards,
RD
guest is offline   Reply With Quote
Old 09-23-2011, 09:08 AM   #12 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 1
lalitpatel is on a distinguished road
Default Increasing the height of a UITextField

txtfield.frame = CGRectMake(txtfield.frame.origin.x, txtfield.frame.origin.y, txtfield.frame.size.width, 44);
lalitpatel is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 341
14 members and 327 guests
akacaj, alexP, ClerurcifeDer, Duncan C, givensur, glenn_sayers, GraffitiCircus, guusleijsten, JmayLive, NetGuru, Paul Slocum, Punkjumper, Sloshmonster, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:45 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0