Centering text in column's of table view

Discussion in 'Mac Programming' started by satyam90, Oct 2, 2008.

  1. satyam90 macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    I am using ObjC with cocoa framework.
    I have a table view with 4 columns. From IB I am able to center the text in columns horizontally. But how to centre the text "Vertically"
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    As far as I know, there's no way to set vertical cell contents alignment either in IB or programmatically, and there sure should be. I think two choices you might look at are using NSAttributedStrings for your cells and adjusting the baseline, or subclassing NSCell to override its drawInteriorWithFrame:inView: method. Either way you'll have to calculate the offset based on the text rectangle and the cell frame.
     
  3. satyam90 thread starter macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #3
    I have NSArrayController with data (strings, date, image etc) available in it and I am binding my table columns to it. So neither I am using seperate NSCell nor I am using NSAttributedStrings...............
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000

Share This Page