How do I make a table view cell size string dependant?

Discussion in 'iOS Programming' started by Niiro13, Oct 2, 2008.

  1. Niiro13 macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #1
    Hi!

    I'm trying to do something similar in my program as Apple does with events in Calendar where the cell for notes is the size of the string that someone entered for notes. If their note is ten lines long, then so is the cell size in the add/edit/details view.

    I cannot figure a way to do this though.

    Can someone point me in the right direction?

    Thanks!
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You will probably need a custom table cell. There is a UITableViewDelegate method for giving a custom height for each row. Also look at the sizeWithFont... methods.
     
  3. Niiro13 thread starter macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #4
    Ahh, thanks!

    I know that a tableview's cells can have different heights. I was having trouble figuring how to get the height of the text.

    Cheers!

    Wow, do I feel stupid. I just read the documentation on the constraintosize method. I supposed I've always assumed that the constrainedtosize part needed the text's size (which was what I was trying to find).
     

Share This Page