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 05-23-2010, 07:32 AM   #24 (permalink)
evana
Registered Member
 
Join Date: Sep 2009
Posts: 98
Default

Quote:
Originally Posted by PhoneyDeveloper View Post
This is a common problem. Tables can have variable height rows. Read the table view programming guide. Here's one example of how to do it. You'll have to figure out your own fudge factor based on the width of your tableviewcell.

Code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
	CGFloat		result = 44.0f;
	NSString*	text = nil;
	CGFloat		width = 0;
	CGFloat		tableViewWidth;
	CGRect		bounds = [UIScreen mainScreen].bounds;
	
	if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
		tableViewWidth = bounds.size.width;
	else
		tableViewWidth = bounds.size.height;

	width = tableViewWidth - 110;		// fudge factor
	text = [self textForRow:indexPath.row];
	
	if (text)
	{
		// The notes can be of any height
		// This needs to work for both portrait and landscape orientations.
		// Calls to the table view to get the current cell and the rect for the 
		// current row are recursive and call back this method.
		CGSize		textSize = { width, 20000.0f };		// width and height of text area
		CGSize		size = [text sizeWithFont:[UIFont systemFontOfSize:12.0f] constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];

		size.height += 29.0f;			// top and bottom margin
		result = MAX(size.height, 44.0f);	// at least one row
	}
	
	return result;
}
Thanks its help me lot....
__________________
Check this Jumping Jack
Hope u will enjoy it
evana is offline   Reply With Quote
 

» Advertisements
» Online Users: 310
21 members and 289 guests
ADY, apatsufas, dacapo, Fit4him, headkaze, HemiMG, ilmman, iosdevjtp, leahov, MarkC, marto1914, morands, PsychoChris, sly24, sneaky, Sunny46, tgjorgoski, thh022, Thrillhouse1919, timle8n1, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,718
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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