Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

r00li

macrumors member
Original poster
Sep 27, 2008
48
0
I have created a custom table cell in interface builder that I am using. I have two problems with it.

The first one - I am using grouped table View and the corners of the cell are not rounded.

Second in that table cell I have a label on the bottom. I want to resize the whole cell and the label if there is too much text to fit. Text is loaded from an NSArray. But I don't know how the resize the cell and the label so that the text can fit.

This is how the cell looks like:
----------------------
|.........| some text
|image|
|.........| other text

resizable text
-----------------------
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Second in that table cell I have a label on the bottom. I want to resize the whole cell and the label if there is too much text to fit. Text is loaded from an NSArray. But I don't know how the resize the cell and the label so that the text can fit.
To resize the cell, look into the UITableViewDelegate method tableView:heightForRowAtIndexPath:.
 

r00li

macrumors member
Original poster
Sep 27, 2008
48
0
I know how resize the cell. Problem is with resizing the label and then resizing the cell. I must resize the label to fit the text before I can resize the cell.
 

r00li

macrumors member
Original poster
Sep 27, 2008
48
0
Yust found a simple method on the internet and simplified it a lot.

Code:
		CGFloat size = 15; //Font size
		
		//Calculate the expected size based on the font and linebreak mode of the label
		CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width - 50;
		CGFloat maxHeight = 9999;
		CGSize maximumLabelSize = CGSizeMake(maxWidth,maxHeight);
		CGSize expectedLabelSize = [[detajli objectAtIndex:3] sizeWithFont:[UIFont systemFontOfSize:size] constrainedToSize:maximumLabelSize lineBreakMode:UILineBreakModeWordWrap]; 
			
		return expectedLabelSize.height + 150;
//[detajli objectAtIndex:3] is a NSString

Now the remaining problem are the section corners. For some reason they are not rounded. They are flat and it looks bad.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
If you inset the views that are at the left and right edges of the cell several pixels you should see the rounded corners. If that doesn't work show a screenshot.
 

r00li

macrumors member
Original poster
Sep 27, 2008
48
0
If you inset the views that are at the left and right edges of the cell several pixels you should see the rounded corners. If that doesn't work show a screenshot.
Great that worked!

Sorry, I wasn't able to detect that based on your first post.
I should probably improve my writing style!:rolleyes:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.