virindh
virindh

Reputation: 3765

TextLabel shifts up when detailTextLabel becomes multiline

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:

How do I stop it from going up and keep it at the center of the cell?

Upvotes: 1

Views: 320

Answers (2)

art-divin
art-divin

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 UILabels and set their position so that:

  1. Title label will not move at all
  2. Detail text label will be also multiline

In this way you'll be able to solve this problem!

Upvotes: 1

Balram Tiwari
Balram Tiwari

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

Related Questions