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

View Single Post
Old 05-05-2009, 04:04 PM   #14 (permalink)
pcmofo
Registered Member
 
Join Date: Oct 2008
Posts: 91
pcmofo is on a distinguished road
Default

Quote:
Originally Posted by yecine06 View Post
How did you manage for the backgournd to fit the content? specially the width of the baloon?
Here is how I did it....

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	ThreadSCell *cell = (ThreadSCell*)[tableView dequeueReusableCellWithIdentifier:@"MsgListCell"];
	
	// If no cell is available, create a new one using the given identifier
	if (cell == nil) {
		cell = [[[ThreadSCell alloc] initWithFrame:CGRectMake(0,0,0,0) reuseIdentifier:@"MsgListCell"] autorelease];
		cell.accessoryType = UITableViewCellAccessoryNone;
	}
	
	
	
	NSMutableDictionary *tempMsg = [myMessages objectAtIndex:indexPath.row];
	
	
	CGFloat	result = 20.0;
	CGSize	textSize = { 260.0, 20000.0 };		// width and height of text area
	
	NSMutableDictionary *dict = [myMessages objectAtIndex:indexPath.row];
	NSString *aMsg = [dict objectForKey:@"msgBody"];
	
	CGSize size = [aMsg sizeWithFont:[UIFont systemFontOfSize:13.0] constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];
	
	result = MAX(size.height + 20, 30.0);
	//NSLog(@"Height for row2:%i %f", indexPath.row, result);
	
	// Set the cell properities 
	[cell.msgText setText:[tempMsg objectForKey:@"msgBody"]];
	[myTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
	[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
	if ( indexPath.row % 2 == 0 ) {
		 
		
		[cell.msgText setFrame:CGRectMake(20.0, 0.0, size.width, cell.frame.size.height-10)];
		//[cell.msgText setBackgroundColor:[UIColor colorWithRed:.788 green:.788 blue:.788 alpha:1]];
		//[cell.msgText setText:[NSString stringWithFormat:@"H1: %f H2: %f", result, cell.frame.size.height]];
		
		UIImage* balloon = [[UIImage imageNamed:@"msgGray.png"] stretchableImageWithLeftCapWidth:24  topCapHeight:15];
		UIImageView *newImage = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, size.width+35, size.height+20)];
		UIView *newView =[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, cell.frame.size.width, cell.frame.size.height)];

		[newImage setImage:balloon];
		[newView addSubview:newImage];
		[cell setBackgroundView:newView];
		
        
		
	}
Basically I create a view the same size as the cell, and a view the size of the balloon. add the balloon view to the cell view and it works. Its kinda hacked together but its good enough for now.
pcmofo is offline   Reply With Quote
 

» Advertisements
» Online Users: 458
17 members and 441 guests
13dario13, 7twenty7, bhsu21, Bryan1, ClerurcifeDer, Duncan C, guusleijsten, HowEver, iAppDeveloper, iekei, ilmman, jessicagx69, Paul Slocum, PavelMik, pbart, Wikiboo, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,637
Threads: 94,101
Posts: 402,822
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jessicagx69
Powered by vBadvanced CMPS v3.1.0

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