Reputation: 3765
i'm currently making an app where the suer selects an MKMapView
annotation and then the title of the annotation(pin) is set to a detailtextLabel
in a Right Detail UITableViewCell
.
My Problem is that when the text is large, the detailTextLabel
becomes multiple lines. When this happens the TextLabel
of the cell(the one the left) shifts up. Heres What I've tried:
In the cellForRowAtIndexPath Method, I tried adjusting the frame through the following code:
CGRect frame = cell.textLabel.frame;
frame.origin.y = cell.frame.size.height/2;
cell.textLabel.frame = frame;
Where cell is a UITableViewCell
that is set to right detail
Subclass the cell and tun try to adjust the frame in the -(void)layoutSubviews
How do I stop it from going up and keep it at the center of the cell?
Upvotes: 1
Views: 320
Reputation: 1645
If you want to do a custom layout of UITableViewCell, then you need to add your custom UI elements to its -[UITableViewCell contentView]
instead of trying to modify geometry of standard UI elements that are created by default.
So, in your case, you need to add two UILabel
s and set their position so that:
In this way you'll be able to solve this problem!
Upvotes: 1
Reputation: 5667
Please try to make the font size adjustable amount to the text. I think you can use,
cell.detailTextLabel.adjustFontSizeToWidth = Yes; And also set the numberOfLines to 0.
Hope that solves the purpose.
Upvotes: 0