-2

i want to know how to give textview at run time on tableviewcell .If i enter multiline text then textview height should be increase and at a same time row also should increase i have only one row and this row i have to put on textview with multiline and growing text with cell height help me in this

Rocky
  • 1,427
  • 1
  • 28
  • 65

3 Answers3

1
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {  

       UITextView *yourtextview;// use your memoir class textview. I am declare here temporary.
       CGSize s = [yourtextview.text sizeWithFont:[UIFont systemFontOfSize:15] // enter your text font size and  cell-width
                    constrainedToSize:CGSizeMake(yourcellwidth, MAXFLOAT)  // - 40 For cell padding
                        lineBreakMode:UILineBreakModeWordWrap];    



       return s.height;    //this will give you height of text view you can change using addition according your requirements
}

Hope, this will help you..

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
Nitin
  • 7,455
  • 2
  • 32
  • 51
  • @nit how to bring keyboard when i follow this code i not get textview on my table view cell when i click on 1row nothing is happen key board is not showing – Rocky May 03 '12 at 12:09
  • you need to use textview in table. you just have to past your textview text in `CGSize s` for calculating textview height. Even you can use this code in function. – Nitin May 03 '12 at 12:17
0

I hope I understand your question correct: You want a UITableView inside a UITableViewCell, both with dynamic height, corresponding to the text in the TextView.

Sensible TableView has this function included (also some more).

This Blog post may also help.

Question from stackoverflow

I hope this links will help you. I think ou can work with the source code from the links to implement that behaviour.

Community
  • 1
  • 1
Sebastian
  • 3,379
  • 2
  • 23
  • 39
0

You can calculate size from your text which is in text view and then you can resize particular row or texview , method is -

CGSize Size = [text sizeWithFont:font constrainedToSize:CGSizeMake(width, 9999) lineBreakMode:UILineBreakModeWorldWrap];

Abhijeet Barge
  • 562
  • 5
  • 21