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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 02-24-2010, 07:58 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 83
Default What's the way to do this?

I need a UIScrollView, and in it I need to display an unknown amount of "title" - "text" blocks, The content of which comes from a database.

I will put the title of each block in a UILabel, and the text in a non-scrollable, user disabled UITextView, but, how can I detect how large my chunk of text is in order to create the UITextField with the correct dimensions to display the entire text ?
djp_phillips is offline   Reply With Quote
Old 02-25-2010, 06:18 PM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 83
Default

I can understand how my question is probably one of those that are very unpopular on forums, I am sorry, I finally found a solution for UILabel, I guess it oculd work for UITextView, but I thought I should share with you this solution:

Adjust UILabel height depending on the text - Stack Overflow.

Code:
//Calculate the expected size based on the font and linebreak mode of your label
CGSize maximumLabelSize = CGSizeMake(296,9999);

CGSize expectedLabelSize = [yourString sizeWithFont:yourLabel.font 
                        constrainedToSize:maximumLabelSize 
                        lineBreakMode:yourLabel.lineBreakMode]; 

//adjust the label the the new height.
CGRect newFrame = yourLabel.frame;
newFrame.size.height = expectedLabelSize.height;
yourLabel.frame = newFrame;
Or even easier:

Code:
[label sizeToFit];

Last edited by djp_phillips; 02-25-2010 at 06:21 PM.
djp_phillips is offline   Reply With Quote
Reply

Bookmarks

Tags
height, text, uilabel, uiscrollview, uitextview

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: 283
17 members and 266 guests
2WeeksToGo, ADY, dacapo, Dani77, Fritzer, ghost, HDshot, headkaze, iDifferent, mer10, mystic.purple, Rudy, smethorst, stoneage, superg, tathaastu, Zool
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,878
Threads: 89,224
Posts: 380,732
Top Poster: BrianSlick (7,129)
Welcome to our newest member, olga2000
Powered by vBadvanced CMPS v3.1.0

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