Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looking at this,you need to be somewhat tricky. You need to calculate the height of the textView dynamically and based on the Height of the TextView,you need to return the Height for the cell..</p> <p>It's very easy &amp; somewhat Tricky..</p> <p>This is the code by which you can calculate the size of string....</p> <p>First get the size of String</p> <pre><code>NSString *label = @"Sample String to get the Size for the textView Will definitely work "; CGSize stringSize = [label sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:UILineBreakModeWordWrap]; over here .... NSLog(@"%f",stringSize.height); </code></pre> <p>Secondly dynamically create the textView in the cell..giving the stringSize.height</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; //} NSDictionary *d=(NSDictionary *)[self.menuArray objectAtIndex:indexPath.section]; NSString *string = [d valueForKey:@"Description"]; CGSize stringSize = [string sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:UILineBreakModeWordWrap]; UITextView *textV=[[UITextView alloc] initWithFrame:CGRectMake(5, 5, 290, stringSize.height+10)]; textV.font = [UIFont systemFontOfSize:15.0]; textV.text=string; textV.textColor=[UIColor blackColor]; textV.editable=NO; [cell.contentView addSubview:textV]; [textV release]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *d=(NSDictionary *)[self.menuArray objectAtIndex:indexPath.section]; NSString *label = [d valueForKey:@"Description"]; CGSize stringSize = [label sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(320, 9999) lineBreakMode:UILineBreakModeWordWrap]; return stringSize.height+25; } </code></pre> <p>After giving so much pain to my fingers,......I think this is enough code...&amp; will surely help to solve your problem..</p> <p>Good Luck</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload