I have a custom cell I'm using to display a variable length subject and body - like a blog post. The cell is pretty basic: two UILables stacked one atop the the other.
The Issue I have is that I want to keep a consistent distance between the two labels regardless of how "tall" they grow to when STV autosizes them. So if the title is one line long or three lines long, I want the summary text to start just a bit below it and not have a wide gap on shorter titles.
I thought I could calculate the size and frame of the title and then adjust the summary label by getting the y coordinate + height + padding, but it doesn't seem to work because it does not appear I am getting the frames after autoresizing has adjusted them.
I realize that this is something that auto layout would handle nicely, however I'm supporting IOS 5 in this project.
So here is my basic custom cell:
SCCustomCell *customCell = [SCCustomCell cellWithText:nil
I am using this in an arrayOfObjectsSection and returning it in sectionActions.cellForRowAtIndexPath ...
I tried to pull the UILabel back out of the custom cell, evaluate their frames height and then adjust them. I can adjust them, but the frame sizes appear to be the same as what they are in the nib so any calculations don't seem to work.
UILabel *titleLabel = (UILabel*)[customCell viewWithTag:1]
UILabel *sumLabel = (UILabel*)[customCell viewWithTag:2];
CGRect tmpframe = sumLabel.frame;
tmpframe.origin.y = titleLabel.frame.origin.y + titleLabel.frame.size.height + 5;
sumLabel.frame = tmpframe;
So, is this the correct way to go about this? Is this the correct place to do it? Any other suggestions would be help!
note: I've started to try recalculating in cellActions.will [configure,style,display]. I'm hoping that is the correct place to make the adjustment.
thanks so much!
Edited by Everett, 03 March 2013 - 07:10 AM.