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

View Single Post
Old 01-29-2009, 07:35 AM   #17 (permalink)
Duncan C
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 4,813
Default

Quote:
Originally Posted by vijayeta View Post
CGSize textSize = { width, 20000.0f };// width and height of text area

can any one please tell me why 20000.0f is used as the height ?? when i try to use the above code snippet , the cell height isnt proper , for text with 1 line it wroks fine , but 2 - 3 lines the cell size is too big.
vijayeta,

The idea is to create a CGSize that's as wide as your text field, but very tall. Then you call the NSString method -sizeWithFont and ask the string how tall it would be at the specified font and field width. To calculate cell height you then need to add the origin.y of the text field, plus any space you need below the text field, to get the final cell height.

Here's a snippet of the code I use in my heightForRowAtIndexPath method:

Code:
	CGSize tempSize;
	CGSize theTextSize;
	tempSize.width = theTableWidth-(10+ 7 + kImageSize);
	tempSize.height = 9999;
	theTextSize = [theText sizeWithFont: theFont constrainedToSize: tempSize];
Duncan C is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,851
Threads: 89,215
Posts: 380,665
Top Poster: BrianSlick (7,129)
Welcome to our newest member, suseline113
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:53 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.