Giving Priority to UITableViewCell label, over accessoryView?

Discussion in 'iOS Programming' started by Aquis, Oct 7, 2008.

  1. Aquis macrumors member

    Aug 7, 2007
    Staffordshire, UK
    Hello all, I have a UITableViewCell in a table with a UILabel for an accessoryView. After assigning the label as the accessory view, I use the sizeToFit method on it to space it out nicely. Unfortunately, when the accessory view is quite long (and, possibly, the main label as well), the label of the UITableViewCell is cropped to make room for the accessoryView label. This results in things like:


    Though I'd like the main label (which fully says "Engineer") to take priority, and have the accessory label be something like "Ingenieurbuero St...", etc.

    I've tried going into the cell using by finding the UITableViewCell's relevant subviews and resizing them, but it doesn't appear to make any effect...

    Thanks for any help!
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    There's no requirement to use accessoryView or the other preexisting contentView stuff. Just add your own subviews to the contentView and make them whatever size you need. The TableViewSuite sample code does this.

    Having said that, making things look good when you have a label and value and the label and value may be arbitrary length is a problem. You may need multiple line UILabels and you may want to use adjustsFontSizeToFitWidth to make the label or value small enough to fit well.

Share This Page